]> Cypherpunks.ru repositories - gostls13.git/commit
archive/tar: fix parsePAXTime
authorJoe Tsai <joetsai@digital-static.net>
Tue, 18 Oct 2016 23:38:54 +0000 (16:38 -0700)
committerJoe Tsai <thebrokentoaster@gmail.com>
Thu, 20 Oct 2016 01:06:09 +0000 (01:06 +0000)
commitef8e85e8b8176fb096683dac00cf536fd7d228bc
tree04d3b2d3e5687b0bd8b1c174104dbee2401acd31
parentf35b8658dca82f317251f7947964fb2878b57a85
archive/tar: fix parsePAXTime

Issues fixed:
* Could not handle quantity of seconds greater than 1<<31 on
32bit machines since strconv.ParseInt did not treat integers as 64b.
* Did not handle negative timestamps properly if nanoseconds were used.
Note that "-123.456" should result in a call to time.Unix(-123, -456000000).
* Incorrectly allowed a '-' right after the '.' (e.g., -123.-456)
* Did not detect invalid input after the truncation point (e.g., 123.123456789badbadbad).

Note that negative timestamps are allowed by PAX, but are not guaranteed
to be portable. See the relevant specification:
<<<
If pax encounters a file with a negative timestamp in copy or write mode,
it can reject the file, substitute a non-negative timestamp, or generate
a non-portable timestamp with a leading '-'.
>>>

Since the previous behavior already partially supported negative timestamps,
we are bound by Go's compatibility rules to keep support for them.
However, we should at least make sure we handle them properly.

Change-Id: I5686997708bfb59110ea7981175427290be737d1
Reviewed-on: https://go-review.googlesource.com/31441
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/archive/tar/strconv.go
src/archive/tar/strconv_test.go