[FIX] Add NULL checks for fopen() and alloc_demuxer_data() in process_hex()#2202
[FIX] Add NULL checks for fopen() and alloc_demuxer_data() in process_hex()#2202Navdeepkaur-11 wants to merge 3 commits intoCCExtractor:masterfrom
Conversation
cfsmp3
left a comment
There was a problem hiding this comment.
Good fix — the NULL checks for both fopen() and alloc_demuxer_data() are correct, braces are in place, and the fclose(fr) cleanup before the second fatal() is a nice touch. Two small things:
1. Wrong exit code for fopen
CCX_COMMON_EXIT_FILE_CREATION_FAILED is for file creation. Since we're opening for reading, use EXIT_READ_ERROR instead:
fatal(EXIT_READ_ERROR, "In process_hex: Unable to open file %s for reading.", filename);2. Drop CHANGES.TXT entry
This is internal hardening, not a user-facing change — no CHANGES.TXT entry needed. (It's also placed above the version header, which is the wrong spot.)
Fix those two and this is ready to merge.
|
Fixed both issues:
|
CCExtractor CI platform finished running the test files on windows. Below is a summary of the test results, when compared to test for commit 578abca...:
Your PR breaks these cases:
NOTE: The following tests have been failing on the master branch as well as the PR:
It seems that not all tests were passed completely. This is an indication that the output of some files is not as expected (but might be according to you). Check the result page for more info. |
CCExtractor CI platform finished running the test files on linux. Below is a summary of the test results, when compared to test for commit 578abca...:
Your PR breaks these cases:
NOTE: The following tests have been failing on the master branch as well as the PR:
Congratulations: Merging this PR would fix the following tests:
It seems that not all tests were passed completely. This is an indication that the output of some files is not as expected (but might be according to you). Check the result page for more info. |
In raising this pull request, I confirm the following (please check boxes):
My familiarity with the project is as follows (check one):
Fixes #2201
Summary
In process_hex() in src/lib_ccx/general_loop.c, two return
values were not checked:
fopen() — if the file cannot be opened, fr is NULL and
the subsequent fgets(fr) call crashes with a segfault.
alloc_demuxer_data() — if allocation fails, data is NULL
and causes undefined behavior when used later.
Fix
cleanup before fatal() to avoid resource leak
Files Changed