Re: [PATCH] scsi: target: Replace deprecated strncpy() with strscpy()
From: Thorsten Blum
Date: Sun Mar 02 2025 - 06:41:29 EST
On 28. Feb 2025, at 21:10, Kees Cook wrote:
> On Wed, Feb 26, 2025 at 01:10:03PM +0100, Thorsten Blum wrote:
>> Since strncpy() is deprecated for NUL-terminated destination buffers,
>> use strscpy() instead.
>>
>> Compile-tested only.
>>
>> Link: https://github.com/KSPP/linux/issues/90
>> Cc: linux-hardening@xxxxxxxxxxxxxxx
>> Signed-off-by: Thorsten Blum <thorsten.blum@xxxxxxxxx>
>> ---
>
> When doing strncpy() to strscpy() conversions, please include details
> of your analysis for several things:
>
> - why is it safe to be NUL-terminated?
> - why is NUL padding needed/not needed?
> - why is the maximum length argument correct?
Yes, I'll try to describe it better.
> While you're in this file, though, can you replace the other strncpy
> that is used in target_init_dbroot() also?
Ah, I missed this one and will submit a v2 soon.
Thanks,
Thorsten