Fix string copy truncation warning. (#1723)

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 <matzeton@googlemail.com>

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
This commit is contained in:
Toni
2022-09-05 11:16:06 +02:00
committed by GitHub
parent 378b0c5953
commit 01028ee779
+2 -2
View File
@@ -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';
}