Re: [PATCH] ksmbd: Replace strcpy + strcat with scnprintf in convert_to_nt_pathname

From: Thorsten Blum

Date: Tue Nov 18 2025 - 20:23:17 EST


On 18. Nov 2025, at 23:35, David Laight wrote:
> On Tue, 18 Nov 2025 13:25:56 +0100
> Thorsten Blum <thorsten.blum@xxxxxxxxx> wrote:
>
>> strcpy() is deprecated and using strcat() is discouraged; use the safer
>> scnprintf() instead. No functional changes.
>>
>> Link: https://github.com/KSPP/linux/issues/88
>> Signed-off-by: Thorsten Blum <thorsten.blum@xxxxxxxxx>
>> ---
>> [...]
>
> Ugg...
> If nothing else non-constant formats are definitely frowned upon.
> Never mind the non-trivial cpu cost of printf.
>
> OTOH once you've got the string length, just use memcpy().
> That way you know you won't overflow the malloc buffer even
> if someone changes the string on you.

Ok, I'll submit a v2.

Thanks,
Thorsten