Skip to content

Bug: Label_QP / Label_QR / Label_QS have no length guard on message.text — short messages emit empty ICAO airports, non-numeric time crashes MessageDecoder.decode() #502

Description

@kevinelliott

Summary

Label_QP, Label_QR, and Label_QS blindly slice message.text at fixed offsets with no length check. Two failure modes fall out of the same missing guard:

  1. Silent-wrong-output: any text under 12 chars is fed straight to text.substring(0,4) / text.substring(4,8) / text.substring(8,12), so the plugin returns decoded: true with empty or truncated ICAO airport codes.
  2. Crash: if chars 8-11 aren't numeric, convertHHMMSSToTod returns NaN, which reaches ResultFormatter.outDateTimeUtils.timestampToString(NaN)RangeError: Invalid time value, aborting the entire MessageDecoder.decode() call.

Location

  • lib/plugins/Label_QP.ts:20-33
  • lib/plugins/Label_QR.ts:20-33
  • lib/plugins/Label_QS.ts:20-33

(Identical shape — same substring math with no length check.) Excerpt:

ResultFormatter.departureAirport(decodeResult, message.text.substring(0, 4));
ResultFormatter.arrivalAirport(decodeResult, message.text.substring(4, 8));
ResultFormatter.out(
  decodeResult,
  DateTimeUtils.convertHHMMSSToTod(message.text.substring(8, 12)),
);

Reproduction

Silent empty ICAO:

new MessageDecoder().decode({ label: 'QP', text: 'AA' });
// -> decoded: true, raw.departure_icao === 'AA', raw.arrival_icao === ''

Crash (garbage time field):

new MessageDecoder().decode({ label: 'QP', text: 'KSDLKLASABCD' });
// -> convertHHMMSSToTod('ABCD') -> NaN
// -> ResultFormatter.out -> timestampToString(NaN) -> RangeError
// -> escapes MessageDecoder.decode()

Impact

The empty-ICAO half is a silent-wrong-output pattern analogous to the empty-lat/lon (0,0) family (#487/#495/#497) but for airport codes; the crash half is a variant of the timestamp-family crash (filed alongside as a separate ResultFormatter issue). Both are reachable from a single unauthenticated ACARS input.

Suggested fix

Require the text to be at least 12 chars and the time field to be numeric before decoding; otherwise emit decodeLevel: 'none' / decoded: false. Applies identically to Label_QP, Label_QR, and Label_QS (and worth auditing Label_QQ variant-3 for the same pattern).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions