[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250317153224647OjWUNNAviyd634961gnCh@zte.com.cn>
Date: Mon, 17 Mar 2025 15:32:24 +0800 (CST)
From: <feng.wei8@....com.cn>
To: <tglx@...utronix.de>
Cc: <darwi@...utronix.de>, <linux-kernel@...r.kernel.org>
Subject: [PATCH] tools/x86/kcpuid: Replace deprecated strncpy() with strscpy()
From: FengWei <feng.wei8@....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@....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
Powered by blists - more mailing lists