Skip to content

Comments

Fix configuration file parsing bugs and typos#2136

Open
apoorvdarshan wants to merge 1 commit intoCCExtractor:masterfrom
apoorvdarshan:fix/config-file-parser-bugs
Open

Fix configuration file parsing bugs and typos#2136
apoorvdarshan wants to merge 1 commit intoCCExtractor:masterfrom
apoorvdarshan:fix/config-file-parser-bugs

Conversation

@apoorvdarshan
Copy link

Summary

  • Fix heap buffer overflow in parse_file() — 128-byte buffer written with no bounds check on long config lines
  • Fix broken EOF detection — fgetc() return stored in char instead of int, causing infinite loop on unsigned-char platforms or premature EOF on 0xFF bytes
  • Fix missing NULL check after malloc(128) — immediate dereference on allocation failure
  • Fix missing null-terminator on accumulated string buffer
  • Fix last config line silently dropped if file lacks trailing newline
  • Fix typos in configuration_map[]: FIX_PADDINDGFIX_PADDING, INVASTIGATE_PACKETINVESTIGATE_PACKET

Test plan

  • Build the project and verify no compilation errors
  • Create a test ccextractor.cnf with a line longer than 127 chars (should be truncated, not overflow)
  • Create a test config file not ending with \n (last line should be parsed)
  • Verify corrected key names FIX_PADDING and INVESTIGATE_PACKET are recognized

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant