Skip to content

[Bug]: Archiver _compressFile func leaks memory, leaks fd on error, and ignores errors. #1439

@jglogan

Description

@jglogan

I have done the following

  • I have searched the existing issues
  • If possible, I've reproduced the issue using the 'main' branch of this project

Steps to reproduce

Should be observable using a build context with a large number of files.

Problem description

container build uses the Archiver type to create an archive of the build context to transfer to the builder VM.

The _compressFile function in Archiver writes a single member entry and its data to the archive. To this end it uses a 1 megabyte buffer, and an input stream. The implementation has several bugs though:

  • Most seriously, it does not deallocate the buffer on exit from the function.
  • The stream is not closed on a throwing error
  • If an error occurs on a read from the stream (negative return value for error in contrast with zero for end of stream), the function silently exits instead of reporting an error.

Environment

- OS: 26
- Xcode: 26
- Container: main

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    builderIssues and features associated with container image building

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions