Skip to contentSkip to conversation

x86/common: Replace deprecated strcpy() with strscpy()

PATCH In review Thorsten Blum 2 participants 2 messages Aug 16, 2025 – Aug 18, 2025 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/common: Replace deprecated strcpy() with strscpy()

strcpy() is deprecated; use strscpy() instead.

---
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/[email protected]/

---
 arch/x86/kernel/cpu/common.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/x86/kernel/cpu/common.c +3 -3
index 34a054181c4d..8aa170762cc7 100644
@@ -184,9 +184,9 @@ static void default_init(struct cpuinfo_x86 *c)
 	if (c->cpuid_level == -1) {
 		/* No cpuid. It must be an ancient CPU */
 		if (c->x86 == 4)
-			strcpy(c->x86_model_id, "486");
+			strscpy(c->x86_model_id, "486");
 		else if (c->x86 == 3)
-			strcpy(c->x86_model_id, "386");
+			strscpy(c->x86_model_id, "386");
 	}
 #endif
 }
@@ -2013,7 +2013,7 @@ static void identify_cpu(struct cpuinfo_x86 *c)
 		const char *p;
 		p = table_lookup_model(c);
 		if (p)
-			strcpy(c->x86_model_id, p);
+			strscpy(c->x86_model_id, p);
 		else
 			/* Last resort... */
 			sprintf(c->x86_model_id, "%02x/%02x",
Signature · 1 line
2.50.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 1 line · Thorsten Blum

strcpy() is deprecated; use strscpy() instead.

Seems like a good NOP to me.

Quoted 35 lines

---
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/[email protected]/

---
 arch/x86/kernel/cpu/common.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/x86/kernel/cpu/common.c +3 -3
index 34a054181c4d..8aa170762cc7 100644
@@ -184,9 +184,9 @@ static void default_init(struct cpuinfo_x86 *c)
 	if (c->cpuid_level == -1) {
 		/* No cpuid. It must be an ancient CPU */
 		if (c->x86 == 4)
-			strcpy(c->x86_model_id, "486");
+			strscpy(c->x86_model_id, "486");
 		else if (c->x86 == 3)
-			strcpy(c->x86_model_id, "386");
+			strscpy(c->x86_model_id, "386");
 	}
 #endif
 }
@@ -2013,7 +2013,7 @@ static void identify_cpu(struct cpuinfo_x86 *c)
 		const char *p;
 		p = table_lookup_model(c);
 		if (p)
-			strcpy(c->x86_model_id, p);
+			strscpy(c->x86_model_id, p);
 		else
 			/* Last resort... */
 			sprintf(c->x86_model_id, "%02x/%02x",