Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Martin Wilck and committed by
Martin K. Petersen
ba69ead9 45349821

+3 -2
+3 -2
drivers/scsi/scsi_devinfo.c
··· 458 458 /* 459 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 463 memcmp(devinfo->vendor, vskip, vmax)) 463 464 continue; 464 465 ··· 467 466 * @model specifies the full string, and 468 467 * must be larger or equal to devinfo->model 469 468 */ 470 - mlen = strlen(devinfo->model); 469 + mlen = strnlen(devinfo->model, sizeof(devinfo->model)); 471 470 if (mmax < mlen || memcmp(devinfo->model, mskip, mlen)) 472 471 continue; 473 472 return devinfo;