New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
archive/tar: invalid header (file worked in Go 1.9, broke in Go 1.10+) #28843
Comments
Go 1.10 and 1.11 can't even parse the tar header anymore (errors with "invalid header"). I'm not sure if this is a bug so I opened an issue here: golang/go#28843 /cc @jbardin
Hi @mitchellh, thank you for filing the issue ! Could you kindly paste a complete code sample so that it is easy to debug this issue ? |
Sure! Expects "extended_header.tar" in the cwd. Made no attempt at cleanup for obvious reasons: package main
import (
"archive/tar"
"os"
)
func main() {
input, err := os.Open("extended_header.tar")
if err != nil {
panic(err)
}
tarR := tar.NewReader(input)
_, err = tarR.Next()
panic(err) // should be nil, but is "invalid header"
} |
Hi @mitchellh, thanks for the reproduction, made it easy to debug. Here's a hexdump of the first 1024 bytes:
At offsets 0x7c..0x88, you see the string How was this file generated? If it was by |
Thanks for the detailed write up! @jbardin do you recall how you made this file? (He made it, not me) I'll ping him on Slack next week too if he doesn't respond here. 😄 |
I'm fairly certain I used git to create this. The |
Oh wait, @dsnet just mentioned that gnu tar does not accept this file. I'll see if I can find out any more info here. |
What version of
Here you see that it correctly reports the filesize as |
Hi @dsnet, thanks for verifying that. I've re-created the test file with git 2.18.0, and our tests now pass. |
Copy. Closing as "working as intended" then. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Input file is this: https://gist.github.com/mitchellh/e89242770d34660a2bc627557b6449c5
(base64 encoded tar file)
The file in question has extended headers. It is identical to the file added in this commit:
hashicorp/go-getter@668c725#diff-0d8d3e8dc13e64092481d7dd63191a0f
What did you expect to see?
No error.
What did you see instead?
Error:
archive/tar: invalid tar header
This was working with Go 1.9, broke in Go 1.10, and is still broken in Go 1.11.
I'm unsure if this was intended or not. I tried looking through various
archive/tar
issues and couldn't find anything definitive and I'm not super familiar with the variety of tar header formats.And note: this works fine with BSD
tar
.The text was updated successfully, but these errors were encountered: