aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorn0k0 <osmocom@hacky.software>2026-06-25 10:20:37 +0200
committern0k0 <osmocom@hacky.software>2026-08-12 14:01:33 +0200
commitaf0e2912057551dab97bbe26e6a41f18a75f3bbb (patch)
tree321fe0faa81c57305aecfbdc59b1d31e94c7014e
parentd6ac32fde99f08b2019a5ca095471456583dc93a (diff)
smpp34_unpack: bound C_OCTET scan with strnlen()
The C_OCTET macro runs strlen() on the attacker-controlled wire buffer before any bounds check. SMPP PDUs are decoded straight out of a buffer sized exactly to the wire command_length with no trailing NUL, so a C-Octet-String field that runs to the end of the buffer without a terminator makes strlen() read past the end of the allocation (out of bounds heap read), and the post-hoc "lenval > left" check runs only after the over-read has already happened. Scan with strnlen(aux, left) so the read can never go past the remaining buffer; if no terminator is found within 'left' bytes, lenval becomes left + 1 and the existing length check rejects the PDU. This issue has been assigned the CVE candidate identifier CAN-2026-2051038. Change-Id: Ie87b16cad0dbdc8ea8397c1b065b8545f23ac814
-rw-r--r--src/smpp34_unpack.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/smpp34_unpack.c b/src/smpp34_unpack.c
index ec73d35..47d34ba 100644
--- a/src/smpp34_unpack.c
+++ b/src/smpp34_unpack.c
@@ -127,7 +127,7 @@ smpp34_unpack(uint32_t type, void* tt, const uint8_t *ptrBuf, int ptrLen)
#define C_OCTET( inst, par, size ){\
- lenval = strlen( (char*) aux ) + 1;\
+ lenval = strnlen((char *)aux, left) + 1;\
if( lenval > left ){\
PUTLOG("[len(%s):%d(%s)]", par, lenval, \
"Value length exceed buffer length");\