Skip to content

ZIP: Fix NULL-dereference for OOXML scans#1552

Merged
val-ms merged 1 commit into
Cisco-Talos:mainfrom
val-ms:CLAM-2837-zip-cleanup-pt2
Aug 15, 2025
Merged

ZIP: Fix NULL-dereference for OOXML scans#1552
val-ms merged 1 commit into
Cisco-Talos:mainfrom
val-ms:CLAM-2837-zip-cleanup-pt2

Conversation

@val-ms

@val-ms val-ms commented Aug 13, 2025

Copy link
Copy Markdown
Contributor

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 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

@val-ms val-ms requested a review from jhumlick August 13, 2025 23:47
@val-ms val-ms force-pushed the CLAM-2837-zip-cleanup-pt2 branch 2 times, most recently from f54cda3 to a8d9b34 Compare August 14, 2025 15:17
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
@val-ms val-ms force-pushed the CLAM-2837-zip-cleanup-pt2 branch from a8d9b34 to 67a7622 Compare August 14, 2025 15:21

@TheRaynMan TheRaynMan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the unzip.c edits.

@val-ms val-ms merged commit 17d0665 into Cisco-Talos:main Aug 15, 2025
22 of 24 checks passed
@val-ms val-ms deleted the CLAM-2837-zip-cleanup-pt2 branch August 15, 2025 01:17
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
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.

3 participants