Skip to content

Initialize zipcmp entries before cleanup - #558

Open
soul-sol wants to merge 1 commit into
nih-at:mainfrom
soul-sol:fix/zipcmp-initialize-entry
Open

Initialize zipcmp entries before cleanup#558
soul-sol wants to merge 1 commit into
nih-at:mainfrom
soul-sol:fix/zipcmp-initialize-entry

Conversation

@soul-sol

@soul-sol soul-sol commented Jul 29, 2026

Copy link
Copy Markdown

Summary

  • initialize each populated zipcmp archive entry before assigning metadata
  • prevent cleanup from freeing an indeterminate extra_fields pointer

list_zip() allocates its entry array with malloc(). In the normal non-paranoid path it sets n_extra_fields to zero but leaves extra_fields uninitialized. archive_deinit() later calls entry_deinit(), which unconditionally frees that pointer.

The existing entry_init() helper already establishes the complete ownership state, so calling it before populating an entry fixes the invalid free without changing comparison behavior.

Verification

  • Before: both zipcmp_zip_dir.test and zipcmp_zip_dir_slash.test abort under ASan in archive_deinit -> entry_deinit -> free.
  • After: both targeted tests pass under ASan/UBSan.
  • Full ASan/UBSan regression suite: 187/187 passed.
  • Existing corpus sweep: 504 runs across zip_read_fuzzer, zip_read_metadata_fuzzer, and zip_read_file_fuzzer; zero sanitizer failures.

Build flags:

CFLAGS="-O1 -g -fsanitize=address,undefined -fno-omit-frame-pointer"
LDFLAGS="-fsanitize=address,undefined"

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.

1 participant