From b834b80f05236a720e0cb73d28ea4c0a42e14809 Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Sun, 12 Jul 2026 19:35:04 -0400 Subject: [PATCH] adsb: fix BDS 2,1 registration character decoding Fix an incorrect bit shift when decoding aircraft registration markings from BDS 2,1 Comm-B messages. Coverity (CID 649088) reported that the expression '(data[7] & 0x1) >> 3' always evaluates to zero, causing one bit of the 6-bit character value to be discarded. The BDS 2,1 aircraft registration marking format encodes seven 6-bit characters. Based on the bit layout defined in ICAO Doc 9871 (Technical Provisions for Mode S Specific Services) and verified against independent implementations such as pyModeS/rs1090, the remaining bit from data[7] is the most significant bit of the character and must be shifted left, not right. Update the extraction to preserve this bit when combining it with the remaining bits from data[8]. Signed-off-by: Robin Getz --- plugins/channelrx/demodadsb/adsbdemodgui.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/channelrx/demodadsb/adsbdemodgui.cpp b/plugins/channelrx/demodadsb/adsbdemodgui.cpp index 86f975e34..6d5c8dd3b 100644 --- a/plugins/channelrx/demodadsb/adsbdemodgui.cpp +++ b/plugins/channelrx/demodadsb/adsbdemodgui.cpp @@ -3899,7 +3899,7 @@ void ADSBDemodGUI::decodeCommB(const QByteArray data, const QDateTime dateTime, c[2] = ((data[5] & 0x7) << 3) | ((data[6] >> 5) & 0x7); c[3] = ((data[6] & 0x1f) << 1) | ((data[7] >> 7) & 0x1); c[4] = ((data[7] >> 1) & 0x1f); - c[5] = ((data[7] & 0x1) >> 3) | ((data[8] >> 3) & 0x1f); + c[5] = ((data[7] & 0x1) << 5) | ((data[8] >> 3) & 0x1f); c[6] = ((data[8] & 0x7) << 3) | ((data[9] >> 5) & 0x7); // Map to ASCII for (int i = 0; i < 7; i++) {