Skip to content

Commit 0620980

Browse files
tianhuaswenlingz
authored andcommitted
dm: use strnlen to replace strlen
Replace strlen function with strnlen function in DM Tracked-On: #3276 Signed-off-by: Tianhua Sun <tianhuax.s.sun@intel.com> Acked-by: Anthony Xu <anthony.xu@intel.com>
1 parent 1e1244c commit 0620980

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

devicemodel/hw/pci/virtio/virtio_gpio.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -652,10 +652,10 @@ virtio_gpio_proc(struct virtio_gpio *gpio, struct iovec *iov, int n)
652652
* command line paremeter, then provide it to UOS,
653653
* otherwise provide the physical name of gpio to UOS.
654654
*/
655-
if (strlen(line->vname))
655+
if (strnlen(line->vname, sizeof(line->vname)))
656656
strncpy(data[i].name, line->vname,
657657
sizeof(data[0].name) - 1);
658-
else if (strlen(line->name))
658+
else if (strnlen(line->name, sizeof(line->name)))
659659
strncpy(data[i].name, line->name,
660660
sizeof(data[0].name) - 1);
661661
}

0 commit comments

Comments
 (0)