Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ba69ead9 authored by Martin Wilck's avatar Martin Wilck Committed by Martin K. Petersen
Browse files

scsi: scsi_devinfo: handle non-terminated strings



devinfo->vendor and devinfo->model aren't necessarily
zero-terminated.

Fixes: b8018b97 "scsi_devinfo: fixup string compare"
Signed-off-by: default avatarMartin Wilck <mwilck@suse.com>
Reviewed-by: default avatarBart Van Assche <bart.vanassche@wdc.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 45349821
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -458,7 +458,8 @@ 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;

@@ -466,7 +467,7 @@ static struct scsi_dev_info_list *scsi_dev_info_list_find(const char *vendor,
			 * @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;