Re: [PATCH v2 1/2] Staging: rts5208: Replace strncpy() with strscpy()

From: Dan Carpenter
Date: Mon Oct 30 2023 - 08:29:09 EST


On Mon, Oct 30, 2023 at 02:59:34PM +0300, Nancy Nyambura wrote:
> warning found by checkpatch.pl script.I replaced the usage of strncpy()
> with strscpy() in the code(line 524) for the buf buffer to improve
> string copying.This is appropriate since strscpy() is used when you want
> to copy a NUL-terminated string and the destination buffer requires
> trailing NUL-padding.
>
> Signed-off-by: Nancy Nyambura <nicymimz@xxxxxxxxx>
> ---
> Changes in v2:
> - Make the commit message more clearer.

Hi Nancy,

Your commit message does not explain why you used strscpy() instead of
strscpy_pad(). I have written a blog that might be helpful.

https://staticthinking.wordpress.com/2023/10/30/strcpy-strncpy-strlcpy-and-strscpy/

regards,
dan carpenter