Skip to contentSkip to conversation

dnsproxy: Suppress GCC warning stringop-overflow

PATCH In review Lukáš Karas 2 participants 2 messages Jun 15, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dnsproxy: Suppress GCC warning stringop-overflow

Hi all.

Recently added check for buffer size breaks build with GCC 10.3.0, its internal analysis suspect that code is not correct. Build fails with error:

'__builtin_strncpy' specified bound depends on the length of the source argument [-Werror=stringop-overflow=]

on src/dnsproxy.c:1794

I not sure if suppressing compiler warning is a good practice in Connman, but it fixes build for me :-)

Lukas

From 3c605b7c2798ba5cb3ae8afdadc31f68337228b0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Karas?= <[email protected]>
Date: Tue, 15 Jun 2021 09:23:39 +0200
Subject: [PATCH] dnsproxy: Suppress GCC warning stringop-overflow
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Recently added check for buffer size breaks build with GCC 10.3.0, its internal analysis suspect that code is not correct. Build fails with error:

'__builtin_strncpy' specified bound depends on the length of the source argument [-Werror=stringop-overflow=]

on src/dnsproxy.c:1794

---
 src/dnsproxy.c | 2 ++
 1 file changed, 2 insertions(+)
src/dnsproxy.c +2 -0
index 38dbdd71..035593e9 100644
@@ -41,6 +41,8 @@
 
 #include "connman.h"
 
+#pragma GCC diagnostic ignored "-Wstringop-overflow"
+
 #define debug(fmt...) do { } while (0)
 
 #if __BYTE_ORDER == __LITTLE_ENDIAN
Signature · 1 line
2.27.0
#1 lore raw
Quoted 11 lines · Lukáš Karas

Recently added check for buffer size breaks build with GCC 10.3.0, its internal analysis suspect that code is not correct. Build fails with error:

'__builtin_strncpy' specified bound depends on the length of the source argument [-Werror=stringop-overflow=]

on src/dnsproxy.c:1794

I not sure if suppressing compiler warning is a good practice in Connman, but it fixes build for me :-)

I would say replacing the strncpy call with a memcpy call would be a better approach. Since all the checks have already been done before the call there's no functional difference, but the compiler wouldn't need to complain about the logic (while from security PoV there's no issue, the warning from the compiler has certain merit).

Signature · 1 line
Santtu