Commit 5bb288c
committed
scsi: mptfusion: 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.
Reported-by: Charles Bertsch <cbertsch@cox.net>
Closes: https://lore.kernel.org/all/5445ba0f-3e27-4d43-a9ba-0cc22ada2fce@cox.net/
Fixes: 45e833f ("scsi: message: fusion: Replace deprecated strncpy() with strscpy()")
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Link: https://lore.kernel.org/r/20240410023155.2100422-2-keescook@chromium.org
Signed-off-by: Kees Cook <keescook@chromium.org>1 parent f700b71 commit 5bb288c
1 file changed
Lines changed: 5 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2964 | 2964 | | |
2965 | 2965 | | |
2966 | 2966 | | |
2967 | | - | |
2968 | | - | |
2969 | | - | |
2970 | | - | |
2971 | | - | |
2972 | | - | |
| 2967 | + | |
| 2968 | + | |
| 2969 | + | |
2973 | 2970 | | |
2974 | 2971 | | |
2975 | | - | |
2976 | | - | |
2977 | | - | |
| 2972 | + | |
| 2973 | + | |
2978 | 2974 | | |
2979 | 2975 | | |
2980 | 2976 | | |
| |||
0 commit comments