mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] tools/x86/kcpuid: Replace deprecated strncpy() with strscpy()
@ 2025-03-17  7:32 feng.wei8
  2025-03-17  8:51 ` Jiri Slaby
  0 siblings, 1 reply; 2+ messages in thread
From: feng.wei8 @ 2025-03-17  7:32 UTC (permalink / raw)
  To: tglx; +Cc: darwi, linux-kernel

From: FengWei <feng.wei8@zte.com.cn>

strncpy() is deprecated for NUL-terminated destination buffers. Use
strscpy() instead and remove the manual NUL-termination.

Signed-off-by: FengWei <feng.wei8@zte.com.cn>
---
 tools/arch/x86/kcpuid/kcpuid.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tools/arch/x86/kcpuid/kcpuid.c b/tools/arch/x86/kcpuid/kcpuid.c
index 1b25c0a95d3f..23a8fde2e203 100644
--- a/tools/arch/x86/kcpuid/kcpuid.c
+++ b/tools/arch/x86/kcpuid/kcpuid.c
@@ -312,8 +312,7 @@ static int parse_line(char *line)
 	if (line[0] == '#' || line[0] == '\n')
 		return 0;

-	strncpy(buffer, line, 511);
-	buffer[511] = 0;
+	strscpy(buffer, line, 511);
 	str = buffer;
 	for (i = 0; i < 5; i++) {
 		tokens[i] = strtok(str, ",");
-- 
2.25.1

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-03-17  8:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-17  7:32 [PATCH] tools/x86/kcpuid: Replace deprecated strncpy() with strscpy() feng.wei8
2025-03-17  8:51 ` Jiri Slaby

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®