Hi, I’d like to request a small public API that lets callers detect when ZipArchive has collapsed duplicate entry names.
Currently, ZipArchive stores entries in an IndexMap keyed by raw filename bytes. That means archives with duplicate central-directory names are accepted, but len(), file_names(), by_name(), and related name-based APIs expose only the deduplicated view. For tools that process untrusted archives, this is risky: a caller may inspect or extract one logical entry while the archive actually contains multiple entries with the same raw name.
has_overlapping_files() helps with overlapping file data, but it does not detect duplicate central-directory names.
The information needed already exists internally while parsing the selected EOCD / Zip64 EOCD. A minimal API could be something like:
impl<R> ZipArchive<R> {
pub fn raw_entry_count(&self) -> u64;
pub fn has_duplicate_names(&self) -> bool;
}
where has_duplicate_names() could be equivalent to:
raw_entry_count > self.len() as u64
A raw central-directory iterator would also work, but for security rejection the raw count alone is enough.
Why this matters: without this API, callers must either re-parse the EOCD/Zip64 metadata themselves and carefully match zip’s parser behavior, or use streaming APIs that require reading through the whole archive just to count entries. The first option is fragile and version-sensitive; the second can be prohibitively expensive for large archives.
This would give downstream tools a cheap, parser-consistent way to reject ambiguous ZIPs with duplicate names while continuing to rely on zip as the source of truth for EOCD and Zip64 parsing.
Hi, I’d like to request a small public API that lets callers detect when
ZipArchivehas collapsed duplicate entry names.Currently,
ZipArchivestores entries in anIndexMapkeyed by raw filename bytes. That means archives with duplicate central-directory names are accepted, butlen(),file_names(),by_name(), and related name-based APIs expose only the deduplicated view. For tools that process untrusted archives, this is risky: a caller may inspect or extract one logical entry while the archive actually contains multiple entries with the same raw name.has_overlapping_files()helps with overlapping file data, but it does not detect duplicate central-directory names.The information needed already exists internally while parsing the selected EOCD / Zip64 EOCD. A minimal API could be something like:
where
has_duplicate_names()could be equivalent to:A raw central-directory iterator would also work, but for security rejection the raw count alone is enough.
Why this matters: without this API, callers must either re-parse the EOCD/Zip64 metadata themselves and carefully match
zip’s parser behavior, or use streaming APIs that require reading through the whole archive just to count entries. The first option is fragile and version-sensitive; the second can be prohibitively expensive for large archives.This would give downstream tools a cheap, parser-consistent way to reject ambiguous ZIPs with duplicate names while continuing to rely on
zipas the source of truth for EOCD and Zip64 parsing.