Browse Source

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 <rgetz503@gmail.com>
chirpmodem-v8.1.0
Robin Getz 4 weeks ago
parent
commit
5e7a45df6d
No known key found for this signature in database
GPG Key ID: 51C7231FFED0E060
  1. 4
      modemdab/dabensemble.cpp

4
modemdab/dabensemble.cpp

@ -968,6 +968,10 @@ void DABEnsemble::fig2(const uint8_t *data, int length) @@ -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<uint16_t>((field[1] << 8) | field[2]);
const int charset = ucs2 ? 6 : 15;

Loading…
Cancel
Save