Skip to content

Commit b65489c

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 5ced5fe commit b65489c

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
@@ -647,10 +647,10 @@ virtio_gpio_proc(struct virtio_gpio *gpio, struct iovec *iov, int n)
647647
* command line paremeter, then provide it to UOS,
648648
* otherwise provide the physical name of gpio to UOS.
649649
*/
650-
if (strlen(line->vname))
650+
if (strnlen(line->vname, sizeof(line->vname)))
651651
strncpy(data[i].name, line->vname,
652652
sizeof(data[0].name) - 1);
653-
else if (strlen(line->name))
653+
else if (strnlen(line->name, sizeof(line->name)))
654654
strncpy(data[i].name, line->name,
655655
sizeof(data[0].name) - 1);
656656
}

0 commit comments

Comments
 (0)