Skip to contentSkip to conversation

arm64/idreg: use strscpy() is more robust and safer

PATCH New [email protected] 1 participant 1 message Sep 29, 2022 arm64

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm64/idreg: use strscpy() is more robust and safer

From: Xu Panda <[email protected]>

The implementation of strscpy() is more robust and safer. That's now the recommended way to copy NUL terminated strings.

---
 arch/arm64/kernel/idreg-override.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kernel/idreg-override.c +1 -1
index 95133765ed29..61bbec7ef62e 100644
@@ -246,7 +246,7 @@ static __init void __parse_cmdline(const char *cmdline, bool parse_aliases)
                        return;
 
                len = min(len, ARRAY_SIZE(buf) - 1);
-               strncpy(buf, cmdline, len);
+               strscpy(buf, cmdline, len);
                buf[len] = 0;
 
                if (strcmp(buf, "--") == 0)
Signature · 6 lines
2.15.2

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel