r22924: Fix the build by correctly processing readX
authorJeremy Allison <jra@samba.org>
Wed, 16 May 2007 01:34:22 +0000 (01:34 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:22:08 +0000 (12:22 -0500)
errors in the direct read case.
Jeremy.

source/libsmb/clientgen.c

index 1a4b1f770f50a85040f4b0eebc7f5b6e3e1b447e..9021d1a36280ba678ac03df4f249b395addd87f8 100644 (file)
@@ -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;
+                       }
                }
        }