Fix NULL pointer dereference in solv_chksum_free()#623
Merged
Conversation
Commit a4f1b2f ("Split the checksum implementation into chksum_impl.c") introduced a NULL pointer dereference in solv_chksum_free(). The refactoring added an else branch that accesses chk->impl to free internal resources, but this branch is reached even when chk is NULL. Before the refactoring, solv_chksum_free(NULL, NULL) was safe: - the "if (cp)" branch was skipped (cp is NULL) - solv_free(NULL) was called, which is a no-op After the refactoring: - the "if (cp)" branch is skipped - the new "else if (chk->impl)" dereferences chk, which is NULL Fix by adding a NULL check for chk at the top of solv_chksum_free(), restoring the pre-refactoring behavior. Signed-off-by: Marek Blaha <mblaha@redhat.com>
Member
|
Thanks! |
Member
|
Fixed in libsolv-0.7.39 |
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.
Commit a4f1b2f ("Split the checksum implementation into chksum_impl.c") introduced a NULL pointer dereference in solv_chksum_free(). The refactoring added an else branch that accesses chk->impl to free internal resources, but this branch is reached even when chk is NULL.
Before the refactoring, solv_chksum_free(NULL, NULL) was safe:
After the refactoring:
Fix by adding a NULL check for chk at the top of solv_chksum_free(), restoring the pre-refactoring behavior.
We noticed segfaults while running libdnf tests after the 0.7.38 release: