From 01028ee77921cb21dee8b0e5f1f912ffd304244a Mon Sep 17 00:00:00 2001 From: Toni Date: Mon, 5 Sep 2022 11:16:06 +0200 Subject: Fix string copy truncation warning. (#1723) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit protocols/ubntac2.c: In function ‘ndpi_search_ubntac2’: protocols/ubntac2.c:69:4: warning: ‘strncpy’ output may be truncated copying between 0 and 31 bytes from a string of length 255 [-Wstringop-truncation] 69 | strncpy(flow->protos.ubntac2.version, (const char *)version, len); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Toni Uhlig Signed-off-by: Toni Uhlig --- src/lib/protocols/ubntac2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/lib/protocols') diff --git a/src/lib/protocols/ubntac2.c b/src/lib/protocols/ubntac2.c index 22262b904..7e56c022f 100644 --- a/src/lib/protocols/ubntac2.c +++ b/src/lib/protocols/ubntac2.c @@ -65,8 +65,8 @@ void ndpi_search_ubntac2(struct ndpi_detection_module_struct *ndpi_struct, struc version[j] = '\0'; - len = ndpi_min(sizeof(flow->protos.ubntac2.version)-1, j); - strncpy(flow->protos.ubntac2.version, (const char *)version, len); + len = ndpi_min(sizeof(flow->protos.ubntac2.version) - 1, j); + memcpy(flow->protos.ubntac2.version, (const char *)version, len); flow->protos.ubntac2.version[len] = '\0'; } -- cgit v1.2.3