Guard vdata_make() against strdup(NULL) for DATA_FORMAT#213
Merged
NorthernMan54 merged 1 commit intoJun 19, 2026
Merged
Conversation
A decoder passing a NULL format to data_make/data_int/data_dbl reaches
vdata_make()'s DATA_FORMAT case, which calls strdup() on the argument
unconditionally. strdup(NULL) is undefined and dereferences a null
pointer, crashing the decoder task with a LoadProhibited exception
(EXCVADDR 0x0) and rebooting the gateway.
This is reachable from normal operation: digitech_xc0324_decode() emits
its 'message_num' field with a NULL format
(data_int(data, "message_num", "Message repeat count", NULL, events)),
so any successful XC-0324 decode -- including the false-positive decodes
that ambient RF noise produces every few hours -- crashes the device.
Captured on an ESP32 as:
Guru Meditation Error: Core 1 panic'ed (LoadProhibited)
... strlen <- _strdup_r <- strdup <- vdata_make <- data_int
<- digitech_xc0324_decode <- pulse_slicer_ppm <- run_ook_demods
Read the format into a temporary and only strdup() it when non-NULL,
leaving format NULL otherwise. A NULL format is legitimate and widely
used; the output backends already treat it as optional (the JSON string
formatter does UNUSED(format)).
Fixes the reboots reported in 1technophile/OpenMQTTGateway#2317.
NorthernMan54
approved these changes
Jun 19, 2026
Owner
|
@1technophile Caught me at the desktop, published as 0.5.1 Tks very much |
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.
A decoder passing a NULL format to data_make/data_int/data_dbl reaches vdata_make()'s DATA_FORMAT case, which calls strdup() on the argument unconditionally. strdup(NULL) is undefined and dereferences a null pointer, crashing the decoder task with a LoadProhibited exception (EXCVADDR 0x0) and rebooting the gateway.
This is reachable from normal operation: digitech_xc0324_decode() emits its 'message_num' field with a NULL format
(data_int(data, "message_num", "Message repeat count", NULL, events)), so any successful XC-0324 decode -- including the false-positive decodes that ambient RF noise produces every few hours -- crashes the device. Captured on an ESP32 as:
Guru Meditation Error: Core 1 panic'ed (LoadProhibited)
... strlen <- _strdup_r <- strdup <- vdata_make <- data_int
<- digitech_xc0324_decode <- pulse_slicer_ppm <- run_ook_demods
Read the format into a temporary and only strdup() it when non-NULL, leaving format NULL otherwise. A NULL format is legitimate and widely used; the output backends already treat it as optional (the JSON string formatter does UNUSED(format)).
Fixes the reboots reported in 1technophile/OpenMQTTGateway#2317.