dm: virtio: use strnlen instead of strlen

Use strnlen instead of strlen to avoid potential security issue.

Tracked-On: #1364
Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Jian Jun Chen
2018-09-29 08:48:06 +08:00
committed by wenlingz
parent 9bf5aafebe
commit b1b3f76db9
2 changed files with 4 additions and 2 deletions

View File

@@ -470,7 +470,8 @@ virtio_input_get_config(struct virtio_input *vi, uint8_t select,
cfg->u.string);
if (rc >= 0) {
cfg->select = VIRTIO_INPUT_CFG_ID_NAME;
cfg->size = strlen(cfg->u.string);
cfg->size = strnlen(cfg->u.string,
sizeof(cfg->u.string));
found = true;
}
break;