1
0
Fork 1
mirror of https://github.com/vbatts/tar-split.git synced 2024-11-25 09:15:40 +00:00
tar-split/archive/tar
Joe Tsai b598ba3ee7 archive/tar: fix issues with readGNUSparseMap1x0
Motivations:
* Use of strconv.ParseInt does not properly treat integers as 64bit,
preventing this function from working properly on 32bit machines.
* Use of io.ReadFull does not properly detect truncated streams
when the file suddenly ends on a block boundary.
* The function blindly trusts user input for numEntries and allocates
memory accordingly.
* The function does not validate that numEntries is not negative,
allowing a malicious sparse file to cause a panic during make.

In general, this function was overly complicated for what it was
accomplishing and it was hard to reason that it was free from
bounds errors. Instead, it has been rewritten and relies on
bytes.Buffer.ReadString to do the main work. So long as invariants
about the number of '\n' in the buffer are maintained, it is much
easier to see why this approach is correct.

Change-Id: Ibb12c4126c26e0ea460ea063cd17af68e3cf609e
Reviewed-on: https://go-review.googlesource.com/15174
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-02 14:17:35 -05:00
..
testdata archive/tar: make output deterministic 2016-02-02 14:10:11 -05:00
common.go archive/tar: make output deterministic 2016-02-02 14:10:11 -05:00
example_test.go archive/tar: adding from go as of a9dddb53f 2015-02-11 14:08:03 +01:00
reader.go archive/tar: fix issues with readGNUSparseMap1x0 2016-02-02 14:17:35 -05:00
reader_test.go archive/tar: fix issues with readGNUSparseMap1x0 2016-02-02 14:17:35 -05:00
stat_atim.go archive/tar: adding from go as of a9dddb53f 2015-02-11 14:08:03 +01:00
stat_atimespec.go archive/tar: adding from go as of a9dddb53f 2015-02-11 14:08:03 +01:00
stat_unix.go archive/tar: don't treat multiple file system links as a tar hardlink 2015-08-21 00:15:22 -04:00
tar_test.go archive/tar: move round-trip reading into common os file 2015-08-21 00:15:22 -04:00
writer.go archive/tar: fix issues with readGNUSparseMap1x0 2016-02-02 14:17:35 -05:00
writer_test.go archive/tar: fix issues with readGNUSparseMap1x0 2016-02-02 14:17:35 -05:00