fix for smbclient giving wrong size on files over 4GB - merge from 2.2
authorHerb Lewis <herb@samba.org>
Tue, 10 Dec 2002 20:13:58 +0000 (20:13 +0000)
committerHerb Lewis <herb@samba.org>
Tue, 10 Dec 2002 20:13:58 +0000 (20:13 +0000)
source/include/client.h
source/include/includes.h
source/libsmb/clilist.c

index 742bb34f58345d72f78ee8784231932be76530da..c26ec76c5a2faf9ed39360b758f526ba59af52cc 100644 (file)
@@ -35,7 +35,7 @@
 
 typedef struct file_info
 {
-       SMB_OFF_T size;
+       SMB_BIG_UINT size;
        uint16 mode;
        uid_t uid;
        gid_t gid;
index 7a8c16ef095425b1b7e5f7db3c9fc1135135518d..a451d155e95edfbf89e824addd33bd74b1a0f9b4 100644 (file)
@@ -542,10 +542,14 @@ typedef int socklen_t;
 #define SOFF_T(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32))
 #define SOFF_T_R(p, ofs, v) (SIVAL(p,(ofs)+4,(v)&0xFFFFFFFF), SIVAL(p,ofs,(v)>>32))
 #define IVAL_TO_SMB_OFF_T(buf,off) ((SMB_OFF_T)(( ((SMB_BIG_UINT)(IVAL((buf),(off)))) & ((SMB_BIG_UINT)0xFFFFFFFF) )))
+#define IVAL2_TO_SMB_BIG_UINT(buf,off) ( (((SMB_BIG_UINT)(IVAL((buf),(off)))) & ((SMB_BIG_UINT)0xFFFFFFFF)) | \
+               (( ((SMB_BIG_UINT)(IVAL((buf),(off+4)))) & ((SMB_BIG_UINT)0xFFFFFFFF) ) << 32 ) )
 #else 
 #define SOFF_T(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
 #define SOFF_T_R(p, ofs, v) (SIVAL(p,(ofs)+4,v),SIVAL(p,ofs,0))
 #define IVAL_TO_SMB_OFF_T(buf,off) ((SMB_OFF_T)(( ((uint32)(IVAL((buf),(off)))) & 0xFFFFFFFF )))
+#define IVAL2_TO_SMB_BIG_UINT(buf,off) ( (((SMB_BIG_UINT)(IVAL((buf),(off)))) & ((SMB_BIG_UINT)0xFFFFFFFF)) | \
+               (( ((SMB_BIG_UINT)(IVAL((buf),(off+4)))) & ((SMB_BIG_UINT)0xFFFFFFFF) ) << 32 ) )
 #endif
 
 /*
index 9bd508f1d7c3913b93d4668cc838d3d1193791ac..d95e347642e97c46c783120fc6bfa1e6a66d5e19 100644 (file)
@@ -50,7 +50,7 @@ static int interpret_long_filename(struct cli_state *cli,
                        finfo->ctime = make_unix_date2(p+4);
                        finfo->atime = make_unix_date2(p+8);
                        finfo->mtime = make_unix_date2(p+12);
-                       finfo->size = IVAL_TO_SMB_OFF_T(p,16);
+                       finfo->size = IVAL(p,16);
                        finfo->mode = CVAL(p,24);
                        len = CVAL(p, 26);
                        p += 27;
@@ -67,7 +67,7 @@ static int interpret_long_filename(struct cli_state *cli,
                        finfo->ctime = make_unix_date2(p+4);
                        finfo->atime = make_unix_date2(p+8);
                        finfo->mtime = make_unix_date2(p+12);
-                       finfo->size = IVAL_TO_SMB_OFF_T(p,16);
+                       finfo->size = IVAL(p,16);
                        finfo->mode = CVAL(p,24);
                        len = CVAL(p, 30);
                        p += 31;
@@ -102,7 +102,7 @@ static int interpret_long_filename(struct cli_state *cli,
                        finfo->ctime = interpret_long_date(p); p += 8;
                        finfo->atime = interpret_long_date(p); p += 8;
                        finfo->mtime = interpret_long_date(p); p += 8; p += 8;
-                       finfo->size = IVAL_TO_SMB_OFF_T(p,0); p += 8;
+                       finfo->size = IVAL2_TO_SMB_BIG_UINT(p,0); p += 8;
                        p += 8; /* alloc size */
                        finfo->mode = CVAL(p,0); p += 4;
                        namelen = IVAL(p,0); p += 4;
@@ -321,7 +321,7 @@ static int interpret_short_filename(struct cli_state *cli, char *p,file_info *fi
        /* this date is converted to GMT by make_unix_date */
        finfo->ctime = make_unix_date(p+22);
        finfo->mtime = finfo->atime = finfo->ctime;
-       finfo->size = IVAL_TO_SMB_OFF_T(p,26);
+       finfo->size = (SMB_BIG_UINT) IVAL(p,26); /* This returns a 4 byte length, not 8 */
        clistr_pull(cli, finfo->name, p+30, sizeof(finfo->name), 12, STR_ASCII);
        if (strcmp(finfo->name, "..") && strcmp(finfo->name, "."))
                fstrcpy(finfo->short_name,finfo->name);
@@ -335,6 +335,7 @@ static int interpret_short_filename(struct cli_state *cli, char *p,file_info *fi
   this uses the old SMBsearch interface. It is needed for testing Samba,
   but should otherwise not be used
   ****************************************************************************/
+
 int cli_list_old(struct cli_state *cli,const char *Mask,uint16 attribute, 
                 void (*fn)(file_info *, const char *, void *), void *state)
 {