Skip to content
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

2024.02.22/stackerfork main/close tarwriter #4

Conversation

mikemccracken
Copy link

this is the same content as opencontainers#534 upstream.

generatelayer closes the tarwriter, but generateinsertlayer forgets to.

Closing the tarwriter writes the required footer of 1k of zeros.

This results in tar files that are complete but invalid, and different
reading tools will behave differently:

- bsdtar doesn't complain and exits 0
- gnu tar (and security scanning tools that use it) will exit 2 with an
unexpected EOF message
- python's tarfile library will raise an Unexpected EOF error
- golang's archive/tar library can raise an unexpected EOF error, but
  for some files created by generateinsertlayer, it just raises a
  plain EOF error, which means golang based tools generally ignore this
  and work fine, this includes umoci.

Signed-off-by: Michael McCracken <[email protected]>
(cherry picked from commit ad29ed3)
This warning is a little confusing when err is nil,
and doesn't add any info in that case. Let's clean that up.

Signed-off-by: Michael McCracken <[email protected]>
(cherry picked from commit 653952b)
add a check to image-verify to ensure that all generated tar blobs are
valid and do not cause gnu tar to exit nonzero

add an insert test that adds a very small file to trigger unexpected EOF
in the case where GenerateInsertLayer forgets to close the TarWriter.

Signed-off-by: Michael McCracken <[email protected]>
(cherry picked from commit 7bb2940)
@hallyn hallyn merged commit bef7765 into project-stacker:main Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants