The branch, v3-2-test has been updated
       via  df3c4648399f8d62ff6fe0013be8b89abc18f0f0 (commit)
      from  bcc94aed6f03211866aa85753a90fece87846ba9 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test


- Log -----------------------------------------------------------------
commit df3c4648399f8d62ff6fe0013be8b89abc18f0f0
Author: Jeremy Allison <[EMAIL PROTECTED]>
Date:   Wed Jan 16 17:33:19 2008 -0800

    Fix bug found by Derrell - windows returns an read return
    offset of zero if return size is zero. Should fix testread
    libsmbclient code.
    Jeremy.

-----------------------------------------------------------------------

Summary of changes:
 source/libsmb/clireadwrite.c |   49 ++++++++++++++++++++++++------------------
 1 files changed, 28 insertions(+), 21 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/libsmb/clireadwrite.c b/source/libsmb/clireadwrite.c
index 6b39a88..af13ed8 100644
--- a/source/libsmb/clireadwrite.c
+++ b/source/libsmb/clireadwrite.c
@@ -134,6 +134,8 @@ ssize_t cli_read(struct cli_state *cli, int fnum, char 
*buf, off_t offset, size_
                                 return -1;
                }
 
+               /* size2 is the number of bytes the server returned.
+                * Might be zero. */
                size2 = SVAL(cli->inbuf, smb_vwv5);
                size2 |= (((unsigned int)(SVAL(cli->inbuf, smb_vwv7))) << 16);
 
@@ -145,27 +147,32 @@ ssize_t cli_read(struct cli_state *cli, int fnum, char 
*buf, off_t offset, size_
                        return -1;
                }
 
-               if (!direct_reads) {
-                       /* Copy data into buffer */
-                       p = smb_base(cli->inbuf) + SVAL(cli->inbuf,smb_vwv6);
-                       memcpy(buf + total, p, size2);
-               } else {
-                       /* Ensure the remaining data matches the return size. */
-                       ssize_t toread = smb_len_large(cli->inbuf) - 
SVAL(cli->inbuf,smb_vwv6);
-
-                       /* Ensure the size is correct. */
-                       if (toread != size2) {
-                               DEBUG(5,("direct read logic fail toread (%d) != 
size2 (%u)\n",
-                                       (int)toread, (unsigned int)size2 ));
-                               return -1;
-                       }
-
-                       /* Read data directly into buffer */
-                       toread = cli_receive_smb_data(cli,buf+total,size2);
-                       if (toread != size2) {
-                               DEBUG(5,("direct read read failure toread (%d) 
!= size2 (%u)\n",
-                                       (int)toread, (unsigned int)size2 ));
-                               return -1;
+               if (size2) {
+                       /* smb_vwv6 is the offset in the packet of the returned
+                        * data bytes. Only valid if size2 != 0. */
+
+                       if (!direct_reads) {
+                               /* Copy data into buffer */
+                               p = smb_base(cli->inbuf) + 
SVAL(cli->inbuf,smb_vwv6);
+                               memcpy(buf + total, p, size2);
+                       } else {
+                               /* Ensure the remaining data matches the return 
size. */
+                               ssize_t toread = smb_len_large(cli->inbuf) - 
SVAL(cli->inbuf,smb_vwv6);
+
+                               /* Ensure the size is correct. */
+                               if (toread != size2) {
+                                       DEBUG(5,("direct read logic fail toread 
(%d) != size2 (%u)\n",
+                                               (int)toread, (unsigned 
int)size2 ));
+                                       return -1;
+                               }
+
+                               /* Read data directly into buffer */
+                               toread = 
cli_receive_smb_data(cli,buf+total,size2);
+                               if (toread != size2) {
+                                       DEBUG(5,("direct read read failure 
toread (%d) != size2 (%u)\n",
+                                               (int)toread, (unsigned 
int)size2 ));
+                                       return -1;
+                               }
                        }
                }
 


-- 
Samba Shared Repository

Reply via email to