Skip to content

Limit archive entry counts - #34

Open
andrew wants to merge 1 commit into
mainfrom
archive-entry-limit
Open

Limit archive entry counts#34
andrew wants to merge 1 commit into
mainfrom
archive-entry-limit

Conversation

@andrew

@andrew andrew commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Reject archives containing more than 100,000 entries. TAR and gem readers enforce the limit as headers are read, while ZIP and conda readers check their indexed entries. Conda also checks the combined entries across members.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a hard cap on the number of entries an archive can contain (default 100,000) to mitigate resource-exhaustion cases across supported archive formats.

Changes:

  • Introduces a shared entry-count limit (maxArchiveEntries) and a common validation helper (checkArchiveEntryCount) with a new sentinel error (ErrEntryLimit).
  • Enforces the limit in TAR and GEM while streaming headers, and in ZIP and CONDA based on their indexed entries (with CONDA also enforcing a cumulative limit across members).
  • Adds test coverage to ensure TAR/ZIP/GEM/CONDA reject archives that exceed the configured entry-count limit.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
zip.go Rejects ZIP archives whose central directory contains too many entries.
tar.go Adds entry-count limit constants/error and enforces the limit while reading TAR headers.
gem.go Tracks and enforces entry count while scanning the outer GEM tar for data.tar.gz.
conda.go Enforces entry-count limits on the outer CONDA zip and cumulatively across member tarballs.
conda_test.go Adds a test verifying CONDA rejects too many combined entries across members.
archives_test.go Adds tests verifying TAR/ZIP/GEM reject archives with too many entries.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tar.go
Comment on lines +129 to +134
func checkArchiveEntryCount(count int) error {
if count > maxArchiveEntries {
return fmt.Errorf("%w: %d entries exceeds %d", ErrEntryLimit, count, maxArchiveEntries)
}
return nil
}
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