Skip to content

Fix out-of-bounds read and NULL dereference when loading transponder JSON - #437

Open
Wahaj18 wants to merge 1 commit into
csete:masterfrom
Wahaj18:fix-434-trsp-json-nul
Open

Wahaj18 wants to merge 1 commit into
csete:masterfrom
Wahaj18:fix-434-trsp-json-nul

Conversation

@Wahaj18

@Wahaj18 Wahaj18 commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Fixes #434.

trsp_update_files() read modes.json and the transmitters file into a buffer of exactly the file size, with no NUL at the end. nx_json_parse() takes no length, so a file cut off inside a string, number or keyword made it read past the buffer, and with a trailing quote or backslash it also wrote past it. Both buffers now get one extra zeroed byte.

nx_json_get() returns a node with a NULL text_value when the key is missing, and that went straight into strncpy(). A mode without name or a transmitter without description now gets skipped instead of crashing.

Tested with a small harness that calls trsp_update_files() built with AddressSanitizer, against master and this branch:

  • valid modes and transmitters: both write the same .trsp file
  • modes.json truncated inside a string: master reports a heap-buffer-overflow, branch parses fine
  • mode with no name: master segfaults in strncpy, branch skips it
  • transmitter with no description: master segfaults, branch skips it

The normal build (-Wall -Wextra -pedantic) has no new warnings.

…JSON

The modes and transmitter JSON files were read into a buffer of exactly
the file size with no terminating NUL. nx_json_parse() takes no length,
so a truncated download could make it read, and in some cases write,
past the end of the buffer. Allocate one extra zeroed byte.

nx_json_get() returns a node with a NULL text_value when a key is
missing, which was passed straight to strncpy(). Skip mode entries
without a name and transmitter entries without a description.

Fixes csete#434
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.

Heap out-of-bounds read/write in gpredict transponder update (missing NUL after JSON load)

1 participant