mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2026-06-08 18:14:53 +00:00
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:
@@ -652,8 +652,10 @@ virtio_net_tap_open(char *devname)
|
||||
memset(&ifr, 0, sizeof(ifr));
|
||||
ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
|
||||
|
||||
if (*devname)
|
||||
if (*devname) {
|
||||
strncpy(ifr.ifr_name, devname, IFNAMSIZ);
|
||||
ifr.ifr_name[IFNAMSIZ - 1] = '\0';
|
||||
}
|
||||
|
||||
rc = ioctl(tunfd, TUNSETIFF, (void *)&ifr);
|
||||
if (rc < 0) {
|
||||
|
||||
Reference in New Issue
Block a user