Forum | Documentation | Website | Blog

Skip to content
Snippets Groups Projects
Commit adb77bba authored by Kees Cook's avatar Kees Cook
Browse files

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: b7e9712a

 ("scsi: mpt3sas: Replace deprecated strncpy() with strscpy()")
Signed-off-by: default avatarKees Cook <keescook@chromium.org>
Tested-by: default avatarMarco Patalano <mpatalan@redhat.com>
Reviewed-by: default avatarEwan D. Milne <emilne@redhat.com>
Reviewed-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Link: https://lore.kernel.org/r/20240410023155.2100422-3-keescook@chromium.org


Signed-off-by: default avatarKees Cook <kees@kernel.org>
parent 1613e604
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment