Skip to content

Commit 2949358

Browse files
committed
archive-tar: huge offset and future timestamps would not work on 32-bit
As we are not yet moving everything to size_t but still using ulong internally when talking about the size of object, platforms with 32-bit long will not be able to produce tar archive with 4GB+ file, and cannot grok 077777777777UL as a constant. Disable the extended header feature and do not test it on them. Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 82246e0 commit 2949358

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

archive-tar.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,13 @@ static int write_tar_filter_archive(const struct archiver *ar,
2525
*
2626
* Likewise for the mtime (which happens to use a buffer of the same size).
2727
*/
28+
#if ULONG_MAX == 0xFFFFFFFF
29+
#define USTAR_MAX_SIZE ULONG_MAX
30+
#define USTAR_MAX_MTIME ULONG_MAX
31+
#else
2832
#define USTAR_MAX_SIZE 077777777777UL
2933
#define USTAR_MAX_MTIME 077777777777UL
34+
#endif
3035

3136
/* writes out the whole block, but only if it is full */
3237
static void write_if_needed(void)

t/t5000-tar-tree.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ test_lazy_prereq TAR_HUGE '
347347
test_cmp expect actual
348348
'
349349

350-
test_expect_success 'set up repository with huge blob' '
350+
test_expect_success LONG_IS_64BIT 'set up repository with huge blob' '
351351
obj_d=19 &&
352352
obj_f=f9c8273ec45a8938e6999cb59b3ff66739902a &&
353353
obj=${obj_d}${obj_f} &&
@@ -360,7 +360,7 @@ test_expect_success 'set up repository with huge blob' '
360360

361361
# We expect git to die with SIGPIPE here (otherwise we
362362
# would generate the whole 64GB).
363-
test_expect_success 'generate tar with huge size' '
363+
test_expect_success LONG_IS_64BIT 'generate tar with huge size' '
364364
{
365365
git archive HEAD
366366
echo $? >exit-code
@@ -369,25 +369,25 @@ test_expect_success 'generate tar with huge size' '
369369
test_cmp expect exit-code
370370
'
371371

372-
test_expect_success TAR_HUGE 'system tar can read our huge size' '
372+
test_expect_success TAR_HUGE,LONG_IS_64BIT 'system tar can read our huge size' '
373373
echo 68719476737 >expect &&
374374
tar_info huge.tar | cut -d" " -f1 >actual &&
375375
test_cmp expect actual
376376
'
377377

378-
test_expect_success 'set up repository with far-future commit' '
378+
test_expect_success LONG_IS_64BIT 'set up repository with far-future commit' '
379379
rm -f .git/index &&
380380
echo content >file &&
381381
git add file &&
382382
GIT_COMMITTER_DATE="@68719476737 +0000" \
383383
git commit -m "tempori parendum"
384384
'
385385

386-
test_expect_success 'generate tar with future mtime' '
386+
test_expect_success LONG_IS_64BIT 'generate tar with future mtime' '
387387
git archive HEAD >future.tar
388388
'
389389

390-
test_expect_success TAR_HUGE 'system tar can read our future mtime' '
390+
test_expect_success TAR_HUGE,LONG_IS_64BIT 'system tar can read our future mtime' '
391391
echo 4147 >expect &&
392392
tar_info future.tar | cut -d" " -f2 >actual &&
393393
test_cmp expect actual

0 commit comments

Comments
 (0)