On 27. Feb 2025, at 23:37, Guenter Roeck wrote:
> On 2/27/25 09:39, Thorsten Blum wrote:
>> 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@vger.kernel.org
>> Signed-off-by: Thorsten Blum <thorsten.b...@linux.dev>
>> ---
> 
> What guarantees that strlen(lstring) < sizeof(label->label) ?

Hi Guenter, I don't think it matters for this patch.

If lstring >= label, strscpy() behaves the same as strncpy() because the
size argument is now one byte larger.

If lstring < label, strscpy() NUL-terminates the destination buffer, but
doesn't add NUL-padding compared to strncpy(). However, this doesn't
matter because label is already zero-initialized.

Thanks,
Thorsten

Reply via email to