-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: write NUL in USTAR header in overflow situations #24599
Comments
CC @dsnet |
This is difficult for me to reproduce as I don't have the docker environment setup. Can you upload the compressed problematic tar file? If that's still too large, the first 1024 bytes will do. |
I reproduced the problem by just creating a 10GiB file, didn't need to do all the docker stuff. Investigating. |
Added some xxd dumps of the first 4096 byte and also a diff to the gist. |
This is a bug in What changed from Go1.9 to Go1.10?In Go1.9, the Thus, for the 10GiB file you are writing, Go1.9 happened to choose the GNU format, which What's wrong with
|
Thanks @dsnet for the fast review and excellent tip for a work around. Indeed, adding the following line header.Format = tar.FormatGNU helps. |
@StefanScherer, great to hear. It turns out that writing NULs in the size field doesn't help |
Thanks for the investigating, @dsnet. Is it correct to say that future versions of go will use the patched version of libarchive, and create valid 8gb PAX archives without manually setting the header format? |
I'm not sure what you mean. |
ah, I misunderstood, for some reason I was thinking golang used the libarchive implementation. Thanks! |
What version of Go are you using (
go version
)?1.10
Does this issue reproduce with the latest release?
yes, also happens with 1.10.1
What operating system and processor architecture are you using (
go env
)?What did you do?
Users start to complaint that Packer 1.2.1 (hashicorp/packer#5990) creates Vagrant box files that cannot be extracted on macOS. These Vagrant boxes are technically tar files with large VM files in it. Packer 1.2.1 is compiled with Golang 1.10, earlier versions were compiled with Golang 1.9. The code to create the tar file hasn't changed in Packer.
I've extracted the problem to a smaller example code and compiled it with different Golang versions.
I have created a gist https://gist.github.com/StefanScherer/9dfeb9fbf6bc5dc35090d698c2703bbc with following files:
createtar.go
- sample code to create a tarout.tar
from an input directoryin
.Dockerfile
- I have compiled the Golang binaries for macOS in a Linux container to easily switch Golang versionstest.sh
- a test script to be called on macOS to build the macOS binaries, the test input file and check the tar files created.dockerignore
- to speed up rebuildsoutput-of-test-sh.txt
- the complete output of the test.sh scriptWhat did you expect to see?
I expect that the tar files produced can be extracted with the built-in tar (bsdtar 2.8.3 - libarchive 2.8.3) in macOS 10.13.3.
What did you see instead?
The binary compiled with Golang 1.9 creates a tarfile with a 10 GByte file in it that can be listed and extracted correctly on macOS.
The binary compiled with Golang 1.10 creates a tarfile with a 10 GByte file in it that can be listed as an empty file. The tarfile itself is 10 GByte. Trying to extract the tar file leads to an error.
The text was updated successfully, but these errors were encountered: