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>
This commit is contained in:
parent
14f06474b8
commit
542849c09c
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user