bus/vmbus: make sure path is null terminated
authorStephen Hemminger <sthemmin@microsoft.com>
Mon, 6 Aug 2018 18:11:07 +0000 (11:11 -0700)
committerThomas Monjalon <thomas@monjalon.net>
Tue, 7 Aug 2018 12:41:47 +0000 (14:41 +0200)
Use strlcpy rather than strncpy to avoid any issues about
null termination.

Coverity issue 302859
Fixes: 831dba47bd36 ("bus/vmbus: add Hyper-V virtual bus support")

Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
drivers/bus/vmbus/linux/vmbus_uio.c

index 0b1b153..bc2c623 100644 (file)
@@ -18,6 +18,7 @@
 #include <rte_common.h>
 #include <rte_malloc.h>
 #include <rte_bus_vmbus.h>
+#include <rte_string_fns.h>
 
 #include "private.h"
 
@@ -89,7 +90,7 @@ vmbus_uio_alloc_resource(struct rte_vmbus_device *dev,
                goto error;
        }
 
-       strncpy((*uio_res)->path, devname, PATH_MAX);
+       strlcpy((*uio_res)->path, devname, PATH_MAX);
        rte_uuid_copy((*uio_res)->id, dev->device_id);
 
        return 0;