Bugzilla – Bug 114540
tar corrupts archives with files >4GB
Last modified: 2005-09-01 09:37:07 UTC
tar corrupts archives with sparse files >4 GB. Testcase follows: % echo "hello" | dd of=x bs=1 seek=4G % ls -l x -rw-rw-r-- 1 szaka szaka 4294967302 Mar 3 22:40 x % tar cSf x.tar x % ls -l x.tar -rw-rw-r-- 1 szaka szaka 10240 Mar 3 22:40 x.tar % tar vtf x.tar -rw-rw-r-- szaka/szaka 4294967302 2005-03-03 22:40:07 x % tar xf x.tar (same result by 'tar xSf x.tar') % ls -l x -rw-rw-r-- 1 szaka szaka 6 Mar 3 22:40 x The thread at http://lists.gnu.org/archive/html/bug-tar/2005-03/msg00004.html has more details. The fix below is already merged in current tar sources. Index: src/sparse.c --- tar-1.15.1/src/sparse.c 2004-09-06 14:30:57.000000000 +0300 +++ tar-1.15.1-n/src/sparse.c 2005-03-04 00:50:05.000000000 +0200 @@ -1,6 +1,6 @@ /* Functions for dealing with sparse files - Copyright (C) 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the @@ -182,7 +182,7 @@ sparse_scan_file (struct tar_sparse_file { static char buffer[BLOCKSIZE]; size_t count; - size_t offset = 0; + off_t offset = 0; struct sp_array sp = {0, 0}; if (!lseek_or_error (file, 0, SEEK_SET))
"The fix below is already merged in current tar sources." Sorry, I was unclear. The fix is already merged in current tar sources, but the latest official tar release is too old to contain the fix. So please merge the patch. Thanks!
Fixed and submitted for STABLE