[PATCH] x86/cyrix: Replace deprecated strcpy() with strscpy()

Thorsten Blum posted 1 patch 1 month, 2 weeks ago
arch/x86/kernel/cpu/cyrix.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
[PATCH] x86/cyrix: Replace deprecated strcpy() with strscpy()
Posted by Thorsten Blum 1 month, 2 weeks ago
strcpy() is deprecated; use strscpy() instead.

Remove the local variable 'char *buf' and call strscpy() directly with
'c->x86_model_id', allowing the compiler to infer the fixed size of the
destination buffer using sizeof().

Link: https://github.com/KSPP/linux/issues/88
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
Note: I already submitted this in April as part of another patch [1]
which doesn't apply anymore. Submitting this again as a separate patch.
[1]: https://lore.kernel.org/lkml/20250425074917.1531-3-thorsten.blum@linux.dev/
---
 arch/x86/kernel/cpu/cyrix.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/cpu/cyrix.c b/arch/x86/kernel/cpu/cyrix.c
index dfec2c61e354..07521e3f94d8 100644
--- a/arch/x86/kernel/cpu/cyrix.c
+++ b/arch/x86/kernel/cpu/cyrix.c
@@ -192,7 +192,6 @@ static void early_init_cyrix(struct cpuinfo_x86 *c)
 static void init_cyrix(struct cpuinfo_x86 *c)
 {
 	unsigned char dir0, dir0_msn, dir0_lsn, dir1 = 0;
-	char *buf = c->x86_model_id;
 	const char *p = NULL;
 
 	/*
@@ -352,9 +351,9 @@ static void init_cyrix(struct cpuinfo_x86 *c)
 		dir0_msn = 7;
 		break;
 	}
-	strcpy(buf, Cx86_model[dir0_msn & 7]);
+	strscpy(c->x86_model_id, Cx86_model[dir0_msn & 7]);
 	if (p)
-		strcat(buf, p);
+		strcat(c->x86_model_id, p);
 	return;
 }
 
@@ -416,7 +415,7 @@ static void cyrix_identify(struct cpuinfo_x86 *c)
 	if (c->x86 == 4 && test_cyrix_52div()) {
 		unsigned char dir0, dir1;
 
-		strcpy(c->x86_vendor_id, "CyrixInstead");
+		strscpy(c->x86_vendor_id, "CyrixInstead");
 		c->x86_vendor = X86_VENDOR_CYRIX;
 
 		/* Actually enable cpuid on the older cyrix */
-- 
2.50.1