bug-tar
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-tar] tar writes invalid mtime for times before the epoch


From: Rodrigo Queiro
Subject: [Bug-tar] tar writes invalid mtime for times before the epoch
Date: Thu, 16 Nov 2017 13:41:49 +0100

Hi bug-tar,

If I use --mtime=1970-01-01 on a machine set to CET (UTC+1), tar will create a file where the mtime field contains non-ASCII bytes and no null character: see the ffff ... f1f0 bytes in the dump below. I've tested with 1.27.1 and 1.29.

I'd expect tar to emit an error.

I discovered this because Python's tarfile module fails to open such files with "invalid header", since it expects this field to contain an ASCII number, as described in the docs:

The mtime field is the data modification time of the file at the time it was archived. It is the ASCII representation of the octal value of the last time the file's contents were modified, represented as an integer number of seconds since January 1, 1970, 00:00 Coordinated Universal Time.

Thanks in advance,
Rodrigo Queiro

> date
Thu Nov 16 13:31:44 CET 2017
> echo > testfile
> tar cf test.tar --mtime 1970-01-01 testfile
> xxd test.tar | head
00000000: 7465 7374 6669 6c65 0000 0000 0000 0000  testfile........
00000010: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000020: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000030: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000040: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000050: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000060: 0000 0000 3030 3030 3634 3000 3133 3133  ....0000640.1313
00000070: 3535 3500 3030 3131 3631 3000 3030 3030  555.0011610.0000
00000080: 3030 3030 3030 3100 ffff ffff ffff ffff  0000001.........
00000090: ffff f1f0 3031 3636 3432 0020 3000 0000  ....016642. 0...

-- 
Google Germany GmbH | Erika-Mann-Strasse | 80636 Muenchen | Germany

AG Hamburg, HRB 86891 | Sitz der Gesellschaft: Hamburg | Geschäftsführer: Paul Manicle, Halimah DeLaine Prado

reply via email to

[Prev in Thread] Current Thread [Next in Thread]