From f6aba4a5a40da233f61be963db7ade15dd007799 Mon Sep 17 00:00:00 2001 From: lwvmobile Date: Sun, 23 Feb 2025 23:52:28 -0500 Subject: [PATCH] DMR: Fix Potential Overflo/Underflow in UTF8 Text; --- src/dmr_pdu.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/dmr_pdu.c b/src/dmr_pdu.c index 7ed5fd0..79320cb 100644 --- a/src/dmr_pdu.c +++ b/src/dmr_pdu.c @@ -30,7 +30,6 @@ void utf16_to_text (uint16_t len, uint8_t * input) void utf8_to_text (uint16_t len, uint8_t * input) { - len -= 24; fprintf (stderr, "\n UTF8 Text: "); for (uint16_t i = 0; i < len; i++) { @@ -49,11 +48,14 @@ void dmr_sd_pdu (dsd_opts * opts, dsd_state * state, uint16_t len, uint8_t * DMR if (DMR_PDU[0] == 0x01) //found some on another system that is 00 here, and not a Loction { - utf8_to_text(len, DMR_PDU+23); + uint16_t offset = 0; //sanity check of sorts, prevent extra long line print outs in the console + if (len >= 22) offset = 22; + utf8_to_text(len-offset, DMR_PDU+offset+1); dmr_locn(opts, state, len, DMR_PDU); } else { + if (len >= (127*18)) len = 127*18; //sanity check of sorts, prevent extra long line print outs in the console utf8_to_text(len, DMR_PDU); //generic catch-all to see if anything relevant is there // utf16_to_text(len, DMR_PDU); //generic catch-all to see if anything relevant is there }