s3-cli: fix bug 563, >8GB tar on BE machines
authorMasafumi Nakayama <MASA23@jp.ibm.com>
Wed, 2 Nov 2011 09:35:19 +0000 (10:35 +0100)
committerKarolin Seeger <kseeger@samba.org>
Mon, 23 Jan 2012 20:29:08 +0000 (21:29 +0100)
Borrows on existing patches proposed by Craig Barratt and Brad Ellis.

Signed-off-by: David Disseldorp <ddiss@suse.de>
Autobuild-User: David Disseldorp <ddiss@samba.org>
Autobuild-Date: Tue Jan  3 18:31:28 CET 2012 on sn-devel-104
(cherry picked from commit 909056a2daacd961b40158b86bc117650a897054)
(cherry picked from commit ab62ee622358362d4d2b16c7fec9a1f2cf7b8d8d)

source3/client/clitar.c

index 542ecca22f2c49a17f25e1fb8865d31b3238d0b0..3c08734e92f0172197ae1a3549f932fa13a59776 100644 (file)
@@ -208,8 +208,10 @@ static void writetarheader(int f, const char *aname, uint64_t size, time_t mtime
 
                memset(hb.dbuf.size, 0, 4);
                hb.dbuf.size[0]=128;
-               for (i = 8, jp=(char*)&size; i; i--)
-                       hb.dbuf.size[i+3] = *(jp++);
+               for (i = 8; i; i--) {
+                       hb.dbuf.size[i+3] = size & 0xff;
+                       size >>= 8;
+               }
        }
        oct_it((uint64_t) mtime, 13, hb.dbuf.mtime);
        memcpy(hb.dbuf.chksum, "        ", sizeof(hb.dbuf.chksum));
@@ -311,7 +313,17 @@ of link other than a GNUtar Longlink - ignoring\n"));
        finfo->mtime_ts = finfo->ctime_ts =
                convert_time_t_to_timespec((time_t)strtol(hb->dbuf.mtime, NULL, 8));
        finfo->atime_ts = convert_time_t_to_timespec(time(NULL));
-       finfo->size = unoct(hb->dbuf.size, sizeof(hb->dbuf.size));
+       if ((hb->dbuf.size[0] & 0xff) == 0x80) {
+               /* This is a non-POSIX compatible extention to extract files
+                       greater than 8GB. */
+               finfo->size = 0;
+               for (i = 0; i < 8; i++) {
+                       finfo->size <<= 8;
+                       finfo->size |= hb->dbuf.size[i+4] & 0xff;
+               }
+       } else {
+               finfo->size = unoct(hb->dbuf.size, sizeof(hb->dbuf.size));
+       }
 
        return True;
 }
@@ -1018,8 +1030,8 @@ static int skip_file(int skipsize)
 static int get_file(file_info2 finfo)
 {
        uint16_t fnum = (uint16_t) -1;
-       int pos = 0, dsize = 0, bpos = 0;
-       uint64_t rsize = 0;
+       int dsize = 0, bpos = 0;
+       uint64_t rsize = 0, pos = 0;
        NTSTATUS status;
 
        DEBUG(5, ("get_file: file: %s, size %.0f\n", finfo.name, (double)finfo.size));