Fix configuration file parsing bugs and typos#2136
Open
apoorvdarshan wants to merge 1 commit intoCCExtractor:masterfrom
Open
Fix configuration file parsing bugs and typos#2136apoorvdarshan wants to merge 1 commit intoCCExtractor:masterfrom
apoorvdarshan wants to merge 1 commit intoCCExtractor:masterfrom
Conversation
Fix multiple bugs in parse_file(): heap buffer overflow on long lines (no bounds check on 128-byte buffer), broken EOF detection (fgetc() return stored in char instead of int), missing NULL check after malloc, missing null-terminator on accumulated string, and last line silently dropped if file lacks trailing newline. Also fix typos in configuration_map[]: FIX_PADDINDG → FIX_PADDING, INVASTIGATE_PACKET → INVESTIGATE_PACKET.
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.
Summary
parse_file()— 128-byte buffer written with no bounds check on long config linesfgetc()return stored incharinstead ofint, causing infinite loop on unsigned-char platforms or premature EOF on0xFFbytesmalloc(128)— immediate dereference on allocation failureconfiguration_map[]:FIX_PADDINDG→FIX_PADDING,INVASTIGATE_PACKET→INVESTIGATE_PACKETTest plan
ccextractor.cnfwith a line longer than 127 chars (should be truncated, not overflow)\n(last line should be parsed)FIX_PADDINGandINVESTIGATE_PACKETare recognized