Re: [PATCH v2] scsi: target: Replace deprecated strncpy() with strscpy()
From: Martin K. Petersen
Date: Mon Mar 10 2025 - 21:20:29 EST
On Sun, 02 Mar 2025 23:56:41 +0100, Thorsten Blum wrote:
> strncpy() is deprecated for NUL-terminated destination buffers; use
> strscpy() instead. The destination buffer db_root is only used with "%s"
> format strings and must therefore be NUL-terminated, but not NUL-padded.
>
> Use scnprintf() because snprintf() could return a value >= DB_ROOT_LEN
> and lead to an out-of-bounds access. This doesn't happen because count
> is explicitly checked against DB_ROOT_LEN before. However, scnprintf()
> always returns the number of characters actually written to the string
> buffer, which is always within the bounds of db_root_stage, and should
> be preferred over snprintf().
>
> [...]
Applied to 6.15/scsi-queue, thanks!
[1/1] scsi: target: Replace deprecated strncpy() with strscpy()
https://git.kernel.org/mkp/scsi/c/dfb7df1ddb29
--
Martin K. Petersen Oracle Linux Engineering