Pktio code uses snprintf instead of strncpy for name copying.

https://bugs.linaro.org/show_bug.cgi?id=1055

CID 85426:  Buffer not null terminated  (BUFFER_SIZE_WARNING)
Calling strncpy with a maximum size argument of 16 bytes on
destination array "pktio_entry->s.name" of size 16 bytes might
leave the destination string unterminated.

Signed-off-by: Maxim Uvarov <maxim.uva...@linaro.org>
---
 platform/linux-generic/odp_packet_io.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/platform/linux-generic/odp_packet_io.c 
b/platform/linux-generic/odp_packet_io.c
index 559b230..c5d0569 100644
--- a/platform/linux-generic/odp_packet_io.c
+++ b/platform/linux-generic/odp_packet_io.c
@@ -251,7 +251,7 @@ static odp_pktio_t setup_pktio_entry(const char *dev, 
odp_pool_t pool)
                id = ODP_PKTIO_INVALID;
                ODP_ERR("Unable to init any I/O type.\n");
        } else {
-               strncpy(pktio_entry->s.name, dev, IFNAMSIZ);
+               snprintf(pktio_entry->s.name, IFNAMSIZ, "%s", dev);
                unlock_entry_classifier(pktio_entry);
        }
 
-- 
1.8.5.1.163.gd7aced9


_______________________________________________
lng-odp mailing list
lng-odp@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to