scsi: elx: sli4: Replace deprecated strncpy() with strscpy()
authorThorsten Blum <thorsten.blum@linux.dev>
Tue, 8 Apr 2025 10:28:40 +0000 (12:28 +0200)
committerMartin K. Petersen <martin.petersen@oracle.com>
Sat, 12 Apr 2025 01:28:16 +0000 (21:28 -0400)
commitcdcb08d5710bc9b543551a85ad551f44d6a4bfc0
tree6f7c4b815b593d0585a8351ccee0e71e8de411db
parent20c74f892645c621df7c1d8e9a0b97793655d4db
scsi: elx: sli4: Replace deprecated strncpy() with strscpy()

strncpy() is deprecated for NUL-terminated destination buffers; use
strscpy() instead.

Since sli_config_cmd_init() already zeroes out the destination buffers,
the potential NUL-padding by strncpy() is unnecessary. strscpy() copies
only the required characters and guarantees NUL-termination.

And since all three destination buffers have a fixed length, strscpy()
automatically determines their size using sizeof() when the argument is
omitted. This makes any explicit sizeof() calls unnecessary.

The source strings are also NUL-terminated and meet the __must_be_cstr()
requirement of strscpy().

No functional changes intended.

Link: https://github.com/KSPP/linux/issues/90
Cc: linux-hardening@vger.kernel.org
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Link: https://lore.kernel.org/r/20250408102843.804083-2-thorsten.blum@linux.dev
Reviewed-by: Kees Cook <kees@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/elx/libefc_sli/sli4.c