aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Wilck <mwilck@suse.com>2017-11-27 17:47:34 -0500
committerMartin K. Petersen <martin.petersen@oracle.com>2017-12-04 21:54:28 -0500
commitba69ead9e9e9bb3cec5faf03526c36764ac8942a (patch)
tree4553dcde881ffec4df460f6a56c7cefb1b83a5ee
parent45349821ab3a8d378b8f37e52c6fe1aa1b870c47 (diff)
scsi: scsi_devinfo: handle non-terminated strings
devinfo->vendor and devinfo->model aren't necessarily zero-terminated. Fixes: b8018b973c7c "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>
-rw-r--r--drivers/scsi/scsi_devinfo.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c
index 78d4aa8df675..b256d4cbd3ad 100644
--- a/drivers/scsi/scsi_devinfo.c
+++ b/drivers/scsi/scsi_devinfo.c
@@ -458,7 +458,8 @@ static struct scsi_dev_info_list *scsi_dev_info_list_find(const char *vendor,
458 /* 458 /*
459 * vendor strings must be an exact match 459 * vendor strings must be an exact match
460 */ 460 */
461 if (vmax != strlen(devinfo->vendor) || 461 if (vmax != strnlen(devinfo->vendor,
462 sizeof(devinfo->vendor)) ||
462 memcmp(devinfo->vendor, vskip, vmax)) 463 memcmp(devinfo->vendor, vskip, vmax))
463 continue; 464 continue;
464 465
@@ -466,7 +467,7 @@ static struct scsi_dev_info_list *scsi_dev_info_list_find(const char *vendor,
466 * @model specifies the full string, and 467 * @model specifies the full string, and
467 * must be larger or equal to devinfo->model 468 * must be larger or equal to devinfo->model
468 */ 469 */
469 mlen = strlen(devinfo->model); 470 mlen = strnlen(devinfo->model, sizeof(devinfo->model));
470 if (mmax < mlen || memcmp(devinfo->model, mskip, mlen)) 471 if (mmax < mlen || memcmp(devinfo->model, mskip, mlen))
471 continue; 472 continue;
472 return devinfo; 473 return devinfo;