ZIP: Fix NULL-dereference for OOXML scans#1552
Merged
Merged
Conversation
f54cda3 to
a8d9b34
Compare
I accidentally introduced a NULL-dereference bug when scanning any OOXML file in Cisco-Talos#1548 I overlooked the test failure out of haste. 😔 The NULL-dereference happens because the `unzip_search()` feature allowed searching some other file than the one that is currently being scanned, which you would do by setting `ctx` to NULL and setting an `fmap` parameter instead. In practice, the current layer's `fmap` from the `ctx` was always passed in. This fix makes it so the `unzip_search()` and related functions only take the `ctx` parameter and do not have and `fmap` or `fsize` field (Note: the `fsize` was never needed, because `fmap->len` take care of that). CLAM-2837
a8d9b34 to
67a7622
Compare
TheRaynMan
approved these changes
Aug 14, 2025
TheRaynMan
left a comment
Contributor
There was a problem hiding this comment.
Thanks for the unzip.c edits.
jhumlick
approved these changes
Aug 14, 2025
jhumlick
pushed a commit
to jhumlick/clamav
that referenced
this pull request
Nov 4, 2025
I accidentally introduced a NULL-dereference bug when scanning any OOXML file in Cisco-Talos#1548 I overlooked the test failure out of haste. 😔 The NULL-dereference happens because the `unzip_search()` feature allowed searching some other file than the one that is currently being scanned, which you would do by setting `ctx` to NULL and setting an `fmap` parameter instead. In practice, the current layer's `fmap` from the `ctx` was always passed in. This fix makes it so the `unzip_search()` and related functions only take the `ctx` parameter and do not have and `fmap` or `fsize` field (Note: the `fsize` was never needed, because `fmap->len` take care of that). CLAM-2837
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I accidentally introduced a NULL-dereference bug when scanning any OOXML file in #1548
I overlooked the test failure out of haste. 😔
The NULL-dereference happens because the
unzip_search()feature allowed searching some other file than the one that is currently being scanned, which you would do by settingctxto NULL and setting anfmapparameter instead.In practice, the current layer's
fmapfrom thectxwas always passed in.This fix makes it so the
unzip_search()and related functions only take thectxparameter and do not have andfmaporfsizefield (Note: thefsizewas never needed, becausefmap->lentake care of that).CLAM-2837