Repository navigation
libclamav: Fix crash on some platforms with optimization enabled. - #1572
Merged
val-ms merged 2 commits intoSep 26, 2025
Merged
Conversation
val-ms
approved these changes
Sep 17, 2025
val-ms
left a comment
Contributor
There was a problem hiding this comment.
I don't think the issue is from optimizing out pointer assignment.
I think the issue is that optimization resulted in different size in memory when packing this struct:
&(struct pdfname_action){"URI", OBJ_DICT, STATE_ANY, STATE_URI, NAMEFLAG_NONE, URI_cb};
versus when packing the larger array of similar structs.
Regardless, I believe this fix is correct to resolve the crash.
val-ms
requested changes
Sep 22, 2025
Some compilers were optimizing out pointer assignment to a structure containing the address of the callback to be called. This resulted in the line calling the callback accessing invalid memory. This fix changes the logic so that rather than assign the pointer to the struct containing the callback, the string that would result in the pointer assignment later on is changed to result in the same assignment. This fixes the issue on all tested platforms. Cisco-Talos#1566 CLAM-2859
val-ms
force-pushed
the
CLAM-2859-github-reported-segfault
branch
from
September 25, 2025 17:22
a41300e to
636224b
Compare
val-ms
approved these changes
Sep 26, 2025
jhumlick
added a commit
to jhumlick/clamav
that referenced
this pull request
Nov 4, 2025
…bled (Cisco-Talos#1572) Compiler optimization results in invalid memory access on some systems with the PDF `pdfname_action` pointer dereference. This fix changes the logic so that rather than assign the pointer to the struct containing the callback, the string that would result in the pointer assignment later on is changed to result in the same assignment. This fixes the issue on all tested platforms. Resolves: Cisco-Talos#1566 CLAM-2859
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.
Some compilers were packing the pdfname_action structure with difference sizes in memory with optimization enabled while assigning a pointer to a member of an array of these structures, resulting in the line calling the callback from said structure accessing invalid memory. This fix changes the logic so that rather than assign the pointer to the struct containing the callback, the string that would result in the pointer assignment later on is changed to result in the same assignment. This fixes the issue on all tested platforms.
#1566
CLAM-2859