Skip to content

Commit

Permalink
scsi: scsi_devinfo: handle non-terminated strings
Browse files Browse the repository at this point in the history
devinfo->vendor and devinfo->model aren't necessarily
zero-terminated.

Fixes: b8018b9 "scsi_devinfo: fixup string compare"
Signed-off-by: Martin Wilck <mwilck@suse.com>
Reviewed-by: Bart Van Assche <bart.vanassche@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
  • Loading branch information
Martin Wilck authored and Martin K. Petersen committed Dec 5, 2017
1 parent 4534982 commit ba69ead
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/scsi/scsi_devinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -458,15 +458,16 @@ static struct scsi_dev_info_list *scsi_dev_info_list_find(const char *vendor,
/*
* vendor strings must be an exact match
*/
if (vmax != strlen(devinfo->vendor) ||
if (vmax != strnlen(devinfo->vendor,
sizeof(devinfo->vendor)) ||
memcmp(devinfo->vendor, vskip, vmax))
continue;

/*
* @model specifies the full string, and
* must be larger or equal to devinfo->model
*/
mlen = strlen(devinfo->model);
mlen = strnlen(devinfo->model, sizeof(devinfo->model));
if (mmax < mlen || memcmp(devinfo->model, mskip, mlen))
continue;
return devinfo;
Expand Down

0 comments on commit ba69ead

Please sign in to comment.