• Joe Tsai's avatar
    archive/tar: validate sparse headers in parsePAX · 3d4ea227
    Joe Tsai authored
    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: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
    3d4ea227
reader.go 25.3 KB