Commit adb77bb
committed
scsi: mpt3sas: Avoid possible run-time warning with long manufacturer strings
The prior strscpy() replacement of strncpy() here expected the
manufacture_reply strings to be NUL-terminated, but it is possible
they are not, as the code pattern here shows, e.g., edev->vendor_id
being exactly 1 character larger than manufacture_reply->vendor_id,
and the replaced strncpy() was copying only up to the size of the
source character array. Replace this with memtostr(), which is the
unambiguous way to convert a maybe not-NUL-terminated character array
into a NUL-terminated string.
Fixes: b7e9712 ("scsi: mpt3sas: Replace deprecated strncpy() with strscpy()")
Signed-off-by: Kees Cook <[email protected]>
Tested-by: Marco Patalano <[email protected]>
Reviewed-by: Ewan D. Milne <[email protected]>
Reviewed-by: Martin K. Petersen <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Kees Cook <[email protected]>1 parent 1613e60 commit adb77bb
2 files changed
+6
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4774 | 4774 | | |
4775 | 4775 | | |
4776 | 4776 | | |
4777 | | - | |
| 4777 | + | |
4778 | 4778 | | |
4779 | 4779 | | |
4780 | 4780 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
458 | 458 | | |
459 | 459 | | |
460 | 460 | | |
461 | | - | |
462 | | - | |
463 | | - | |
464 | | - | |
465 | | - | |
466 | | - | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
467 | 464 | | |
468 | 465 | | |
469 | | - | |
470 | | - | |
471 | | - | |
| 466 | + | |
| 467 | + | |
472 | 468 | | |
473 | 469 | | |
474 | 470 | | |
| |||
0 commit comments