Skip to content

Small archive extraction fixes; support bzip2 archives#479

Merged
egibs merged 2 commits intochainguard-dev:mainfrom
egibs:fix-archive-eof
Oct 2, 2024
Merged

Small archive extraction fixes; support bzip2 archives#479
egibs merged 2 commits intochainguard-dev:mainfrom
egibs:fix-archive-eof

Conversation

@egibs
Copy link
Member

@egibs egibs commented Oct 2, 2024

We noticed a few issues around extracting archives and I also noticed that we never added bzip2 support.

This PR:

  • fixes a bug where we wouldn't seek to the file origin for .apk, .gz, and .tar.gz files (that statement never ran tf.Seek(0, io.SeekStart)) by moving the seek code out of the switch statements
  • fixes a bug where we didn't check for io.ErrUnexpectedEOF when iterating through the tar reader
  • adds bzip2 archive support

@egibs egibs requested a review from tstromberg October 2, 2024 16:42
if err != nil {
return fmt.Errorf("failed to seek to start: %w", err)
}
br := bzip2.NewReader(tf)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's weird that bzip2.NewReader only returns an io.Reader instead of (io.Reader, err). It would be nice to do some error checking like we do with gzip.NewReader. 😞

Signed-off-by: egibs <20933572+egibs@users.noreply.github.com>
@egibs egibs merged commit 19e37ec into chainguard-dev:main Oct 2, 2024
@egibs egibs deleted the fix-archive-eof branch October 2, 2024 17:59
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