[PATCH] tools/x86/kcpuid: bound CSV field copies to avoid overflow

rafad900 <[email protected]> Sat, 2 May 2026 15:10:30 -0700
Newsgroups dev.linux.lists.x86-cpuid,org.kernel.vger.linux-kernel
Message-ID <20260502221030.1081829-1-19312533+rafad900@users.noreply.github.com>
I added bounded copies of the bit descriptions to avoid possible
overflows. I tested by compiling the tool and scp into qemu along with
the .csv file. Then ran the tool and saw no errors

Signed-off-by: rafad900 <[email protected]>
---
 tools/arch/x86/kcpuid/kcpuid.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/arch/x86/kcpuid/kcpuid.c b/tools/arch/x86/kcpuid/kcpuid.c
index 7dc6b9235d02..c17dbcf453eb 100644
--- a/tools/arch/x86/kcpuid/kcpuid.c
+++ b/tools/arch/x86/kcpuid/kcpuid.c
@@ -415,8 +415,8 @@ static void parse_line(char *line)
 
 		bdesc->end = bit_end;
 		bdesc->start = bit_start;
-		strcpy(bdesc->simp, strtok(tokens[4], " \t"));
-		strcpy(bdesc->detail, tokens[5]);
+		strncpy(bdesc->simp, strtok(tokens[4], " \t"), sizeof(bdesc->simp) - 1);
+		strncpy(bdesc->detail, tokens[5], sizeof(bdesc->detail) - 1);
 	}
 	return;
 
-- 
2.43.0