summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorJianfeng Tan <jianfeng.tan@intel.com>2016-06-29 09:05:36 +0000
committerYuanhan Liu <yuanhan.liu@linux.intel.com>2016-07-05 13:30:25 +0200
commit542849c09c2fc9dc4beed5e7e23a1dc2a3f40e86 (patch)
tree17c48984a31725807a65ddec8c188b42c635baa5 /drivers
parent14f06474b8b961f99d85028153155515dd38559c (diff)
downloaddpdk-542849c09c2fc9dc4beed5e7e23a1dc2a3f40e86.zip
dpdk-542849c09c2fc9dc4beed5e7e23a1dc2a3f40e86.tar.gz
dpdk-542849c09c2fc9dc4beed5e7e23a1dc2a3f40e86.tar.xz
net/virtio-user: fix string unterminated
When use strcpy() to copy string with length exceeding the last parameter of strcpy(), it may lead to the destination string unterminated. We replaced strncpy with snprintf to make sure it's NULL terminated. Coverity issue: 127476 Fixes: ce2eabdd43ec ("net/virtio-user: add virtual device") Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com> Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/virtio/virtio_user/virtio_user_dev.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
index 1b1e5bf..376c9cf 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
@@ -181,7 +181,7 @@ int
virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues,
int cq, int queue_size, const char *mac)
{
- strncpy(dev->path, path, PATH_MAX);
+ snprintf(dev->path, PATH_MAX, "%s", path);
dev->max_queue_pairs = queues;
dev->queue_pairs = 1; /* mq disabled by default */
dev->queue_size = queue_size;