From f82fb9c853e95bd6ca206537adfac5c7eaa990fc Mon Sep 17 00:00:00 2001 From: groveer Date: Thu, 8 Oct 2026 15:11:06 +0800 Subject: [PATCH] fix(daemon): suppress GCC 16 -Warray-bounds false positive MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Wrap the ControlHeader memcpy in DdeSeatdControl with a local GCC -Warray-bounds suppression and document why the copy is in bounds. 2. The while loop above already guarantees the buffer holds at least sizeof(ControlHeader) bytes, so the copy is in bounds. GCC 15/16 cannot relate QByteArray::size() to the pointer returned by constData(), which may be the 1-byte static QByteArray::_empty. 3. No wire format, byte order or runtime behaviour change. Log: No user-facing changes Influence: 1. Build ddm on Arch Linux (GCC 16, -Werror) and confirm it passes. 2. Check that DdeSeatdControl.cpp:391 no longer emits array-bounds. 3. Verify dde-seatd control messages are still received correctly. fix(daemon): 抑制 GCC 16 对 constData() 的 -Warray-bounds 误报 1. 在 DdeSeatdControl 中对 ControlHeader 的 memcpy 局部关闭 GCC 的 -Warray-bounds 告警,并注明该拷贝在界内的原因。 2. 上方 while 循环已保证缓冲区长度不小于 sizeof(ControlHeader); GCC 15/16 无法把 QByteArray::size() 与 constData() 返回的指针 关联,后者可能指向 1 字节静态 QByteArray::_empty,故为误报。 3. 不改变线格式、字节序与运行时行为。 Log: 无用户可见变化 Influence: 1. 在 Arch Linux(GCC 16、-Werror)下构建 ddm,确认通过。 2. 确认 DdeSeatdControl.cpp:391 不再报 array-bounds。 3. 验证 dde-seatd 控制消息仍能正常收发。 Multica Issue: WM-566 --- src/daemon/DdeSeatdControl.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/daemon/DdeSeatdControl.cpp b/src/daemon/DdeSeatdControl.cpp index 70c6130..f871f34 100644 --- a/src/daemon/DdeSeatdControl.cpp +++ b/src/daemon/DdeSeatdControl.cpp @@ -388,7 +388,14 @@ void DdeSeatdControl::handleEventSocket() { m_eventBuffer.append(chunk); while (m_eventBuffer.size() >= static_cast(sizeof(ControlHeader))) { ControlHeader header {}; + // The loop condition above guarantees the buffer holds at least sizeof(ControlHeader) + // bytes, so this copy is in bounds. GCC 15/16 nevertheless reports -Warray-bounds here: + // it cannot relate QByteArray::size() to the pointer returned by constData(), which may + // be the 1-byte static QByteArray::_empty for an empty byte array. + QT_WARNING_PUSH + QT_WARNING_DISABLE_GCC("-Warray-bounds") memcpy(&header, m_eventBuffer.constData(), sizeof(header)); + QT_WARNING_POP if (header.size > maxControlPayloadSize) { qWarning("Invalid dde-seatd control message size %u", header.size); disconnectEventSocket();