• Joe Tsai's avatar
    archive/tar: check for permissible output formats first · ead6255c
    Joe Tsai authored
    The current logic in writeHeader attempts to encode the Header in one
    format and if it discovered that it could not it would attempt to
    switch to a different format mid-way through. This makes it very
    hard to reason about what format will be used in the end and whether
    it will even be a valid format.
    
    Instead, we should verify from the start what formats are allowed
    to encode the given input Header. If no formats are possible,
    then we can return immediately, rejecting the Header.
    
    For now, we continue on to the hairy logic in writeHeader, but
    a future CL can split that logic up and specialize them for each
    format now that we know what is possible.
    
    Update #9683
    Update #12594
    
    Change-Id: I8406ea855dfcb8b478a03a7058ddf8b2b09d46dc
    Reviewed-on: https://go-review.googlesource.com/54433
    Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
    Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
    ead6255c
tar_test.go 11.6 KB