From bfb863c57cd1b8fc16cf7cda3cc3989104b4246c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 16 May 2007 01:34:22 +0000 Subject: r22924: Fix the build by correctly processing readX errors in the direct read case. Jeremy. (This used to be commit 6fe2ee3bd79fadfe43a9a84e03c398bd339259c1) --- source3/libsmb/clientgen.c | 46 +++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) (limited to 'source3/libsmb/clientgen.c') diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c index 1a4b1f770f..9021d1a362 100644 --- a/source3/libsmb/clientgen.c +++ b/source3/libsmb/clientgen.c @@ -249,30 +249,34 @@ BOOL cli_receive_smb_readX_header(struct cli_state *cli) } } - /* Check it's a non-chained readX reply. */ - if (!(CVAL(cli->inbuf, smb_flg) & FLAG_REPLY) || - (CVAL(cli->inbuf,smb_vwv0) != 0xFF) || - (CVAL(cli->inbuf,smb_com) != SMBreadX)) { + /* If it's not the above size it probably was an error packet. */ + + if ((len == (smb_size - 4) + 24) && !cli_is_error(cli)) { + /* Check it's a non-chained readX reply. */ + if (!(CVAL(cli->inbuf, smb_flg) & FLAG_REPLY) || + (CVAL(cli->inbuf,smb_vwv0) != 0xFF) || + (CVAL(cli->inbuf,smb_com) != SMBreadX)) { + /* + * We're not coping here with asnyc replies to + * other calls. Punt here - we need async client + * libs for this. + */ + goto read_err; + } + /* - * We're not coping here with asnyc replies to - * other calls. Punt here - we need async client - * libs for this. + * We know it's a readX reply - ensure we've read the + * padding bytes also. */ - goto read_err; - } - /* - * We know it's a readX reply - ensure we've read the - * padding bytes also. - */ - - offset = SVAL(cli->inbuf,smb_vwv6); - if (offset > len) { - ssize_t ret; - size_t padbytes = offset - len; - ret = cli_receive_smb_data(cli,smb_buf(cli->inbuf),padbytes); - if (ret != padbytes) { - goto read_err; + offset = SVAL(cli->inbuf,smb_vwv6); + if (offset > len) { + ssize_t ret; + size_t padbytes = offset - len; + ret = cli_receive_smb_data(cli,smb_buf(cli->inbuf),padbytes); + if (ret != padbytes) { + goto read_err; + } } } -- cgit