]> Cypherpunks repositories - gostls13.git/commit
archive/tar: validate sparse headers in parsePAX
authorJoe Tsai <joetsai@digital-static.net>
Wed, 19 Oct 2016 00:22:25 +0000 (17:22 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Sat, 22 Oct 2016 16:35:14 +0000 (16:35 +0000)
commit3d4ea227c6b8062c436fc9417034f2d01cf8c82c
treeb2627d511a6f6e7aaa225d132ea15d16592a05fb
parentece4e23d9aaed3e11f7a0b9a3f15c592c96b065d
archive/tar: validate sparse headers in parsePAX

According to the GNU manual, the format is:
<<<
GNU.sparse.size=size
GNU.sparse.numblocks=numblocks
repeat numblocks times
  GNU.sparse.offset=offset
  GNU.sparse.numbytes=numbytes
end repeat
>>>

The logic in parsePAX converts the repeating sequence of
(offset, numbytes) pairs (which is not PAX compliant) into a single
comma-delimited list of numbers (which is now PAX compliant).

Thus, we validate the following:
* The (offset, numbytes) headers must come in the correct order.
* The ',' delimiter cannot appear in the value.
We do not validate that the value is a parsible decimal since that
will be determined later.

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