[PATCH v2] RISC-V: cpu: refactor deprecated strncpy

Conor Dooley conor at kernel.org
Wed Aug 2 13:22:41 PDT 2023


On Wed, Aug 02, 2023 at 12:21:58AM +0000, Justin Stitt wrote:
> `strncpy` is deprecated for use on NUL-terminated destination strings [1].
> 
> Favor not copying strings onto stack and instead use strings directly.
> This avoids hard-coding sizes and buffer lengths all together.
> 
> Link: https://github.com/KSPP/linux/issues/90
> Cc: linux-hardening at vger.kernel.org
> Suggested-by: Kees Cook <keescook at chromium.org>
> Signed-off-by: Justin Stitt <justinstitt at google.com>
> ---
> Changes in v2:
> - Use strings directly instead of copying onto stack with `strscpy` (thanks Kees)

Yeah, that is what I was thinking of when I decried it as being horrid.
Reviewed-by: Conor Dooley <conor.dooley at microchip.com>

Thanks,
Conor.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-riscv/attachments/20230802/fe5b0a9c/attachment.sig>


More information about the linux-riscv mailing list