dm: use strncpy to replace strcpy

Use strncpy instead of strcpy to avoid buf overflow.
Fix strncpy null-terminated issues.

Tracked-On: #3245
Signed-off-by: Tianhua Sun <tianhuax.s.sun@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
This commit is contained in:
Tianhua Sun
2019-06-11 10:22:27 +08:00
committed by wenlingz
parent 0ea788b48e
commit 1e1244c36b
5 changed files with 10 additions and 3 deletions

View File

@@ -217,6 +217,7 @@ virtio_rnd_kernel_dev_set(struct vbs_dev_info *kdev, const char *name,
/* init kdev */
strncpy(kdev->name, name, VBS_NAME_LEN);
kdev->name[VBS_NAME_LEN - 1] = '\0';
kdev->vmid = vmid;
kdev->nvq = nvq;
kdev->negotiated_features = feature;