Skip to content
Snippets Groups Projects
Commit d9cf16c0 authored by Xie Yongji's avatar Xie Yongji Committed by Kevin Wolf
Browse files

libvduse: Replace strcpy() with strncpy()


Coverity reported a string overflow issue since we copied
"name" to "dev_config->name" without checking the length.
This should be a false positive since we already checked
the length of "name" in vduse_name_is_invalid(). But anyway,
let's replace strcpy() with strncpy() (as a general library,
we'd like to minimize dependencies on other libraries, so we
didn't use g_strlcpy() here) to fix the coverity complaint.

Fixes: Coverity CID 1490224
Signed-off-by: default avatarXie Yongji <xieyongji@bytedance.com>
Reviewed-by: default avatarMarkus Armbruster <armbru@redhat.com>
Message-Id: <20220706095624.328-3-xieyongji@bytedance.com>
Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
parent e7156ff7
No related branches found
No related tags found
No related merge requests found
...@@ -1309,7 +1309,8 @@ VduseDev *vduse_dev_create(const char *name, uint32_t device_id, ...@@ -1309,7 +1309,8 @@ VduseDev *vduse_dev_create(const char *name, uint32_t device_id,
goto err_dev; goto err_dev;
} }
strcpy(dev_config->name, name); strncpy(dev_config->name, name, VDUSE_NAME_MAX);
dev_config->name[VDUSE_NAME_MAX - 1] = '\0';
dev_config->device_id = device_id; dev_config->device_id = device_id;
dev_config->vendor_id = vendor_id; dev_config->vendor_id = vendor_id;
dev_config->features = features; dev_config->features = features;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment