From ee24189bd2a13a27f58f6dfd6715c41a51bf1509 Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Sun, 2 Aug 2026 18:53:58 -0400 Subject: [PATCH] modais: Initialize output bytes before HDLC bit packing The HDLC encoder accumulated bits into m_bits using the |= operator without first initializing the first byte. This resulted in an uninitialized read of m_bits[0] when encoding the first bit of a packet. Initialize each output byte when writing its first bit, ensuring the buffer contains a defined value before bits are OR'ed into it. This also makes addBit() self-contained, eliminating the need for callers to pre-initialize the current output byte. Reported by Coverity. Signed-off-by: Robin Getz --- plugins/channeltx/modais/aismodsource.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/channeltx/modais/aismodsource.cpp b/plugins/channeltx/modais/aismodsource.cpp index 06e586b24..7207eec46 100644 --- a/plugins/channeltx/modais/aismodsource.cpp +++ b/plugins/channeltx/modais/aismodsource.cpp @@ -412,6 +412,9 @@ int AISModSource::getBit() void AISModSource::addBit(int bit) { + if (m_bitIdx == 0) + m_bits[m_byteIdx] = 0; + // Transmit LSB first m_bits[m_byteIdx] |= bit << m_bitIdx; m_bitIdx++;