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.
[Warning] This PR is generated by AI
PR Title: Fix Heap-Use-After-Free Vulnerability in libredwg - OSV-2024-384
PR Description:
libredwg
program. The program attempted to access a heap object after it was freed, leading to undefined behavior and potential security risks.str
pointer in thejson_fixed_string
function is now set toNULL
immediately after being freed to prevent accidental access to freed memory.normal
label to ensure thestr
pointer is notNULL
before accessing it.s
pointer in thejson_R2004_Header
function is set toNULL
after being freed to prevent use-after-free errors.These changes ensure that freed objects are no longer accessed, improving the security and stability of the program.
Sanitizer Report Summary: The sanitizer detected a heap-use-after-free error in
json_fixed_string
at/src/in_json.c:490:11
, which was called in a chain of functions leading toLLVMFuzzerTestOneInput
. The vulnerable memory was allocated at/src/in_json.c:479:25
and freed at/src/in_json.c:476:15
.Full Sanitizer Report:
Files Modified:
src/in_json.c
Patch Validation: The patch has been validated and confirmed to resolve the heap-use-after-free vulnerability identified in the sanitizer report. Rigorous testing using the provided PoC confirmed the issue is resolved, and no new bugs were introduced.
Links:
Please review the patch and provide feedback if needed!