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>
This commit is contained in:
Tianhua Sun 2019-06-12 15:23:14 +08:00 committed by wenlingz
parent 5ced5fe77f
commit b65489c27d

View File

@ -647,10 +647,10 @@ virtio_gpio_proc(struct virtio_gpio *gpio, struct iovec *iov, int n)
* command line paremeter, then provide it to UOS,
* otherwise provide the physical name of gpio to UOS.
*/
if (strlen(line->vname))
if (strnlen(line->vname, sizeof(line->vname)))
strncpy(data[i].name, line->vname,
sizeof(data[0].name) - 1);
else if (strlen(line->name))
else if (strnlen(line->name, sizeof(line->name)))
strncpy(data[i].name, line->name,
sizeof(data[0].name) - 1);
}