From 5e7a45df6dd2d7d74a71868342cfea5d23c2d2e2 Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Mon, 26 Oct 2026 17:22:15 -0400 Subject: [PATCH] modemdab: Validate FIG 2 label field length Check that the assembled label field contains at least three bytes before reading its character-set indicator and flags. Short or malformed label data could otherwise cause out-of-bounds access. Identified by cppcheck. Signed-off-by: Robin Getz --- modemdab/dabensemble.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modemdab/dabensemble.cpp b/modemdab/dabensemble.cpp index e0d0523ee..4e11c8ac9 100644 --- a/modemdab/dabensemble.cpp +++ b/modemdab/dabensemble.cpp @@ -968,6 +968,10 @@ void DABEnsemble::fig2(const uint8_t *data, int length) field.insert(field.end(), label.segments[i].begin(), label.segments[i].end()); } + if (field.size() < 3) { + return; + } + const bool ucs2 = (field[0] & 0x80) != 0; const uint16_t flags = static_cast((field[1] << 8) | field[2]); const int charset = ucs2 ? 6 : 15;