Skip to contentSkip to conversation

alpha-replace-sprintf-strcpy-with-scnprintf-strscpy.patch removed from -mm tree

merged mm-nonmm-stable Andrew Morton 1 participant 1 message Jul 10, 2025

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: alpha: replace sprintf()/strcpy() with scnprintf()/strscpy()
has been removed from the -mm tree. Its filename was
alpha-replace-sprintf-strcpy-with-scnprintf-strscpy.patch

This patch was dropped because it was merged into the mm-nonmm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Thorsten Blum <[email protected]>
Subject: alpha: replace sprintf()/strcpy() with scnprintf()/strscpy()
Date: Wed, 21 May 2025 14:18:38 +0200

Replace sprintf() with the safer variant scnprintf() and use its return value instead of calculating the string length again using strlen().

Use strscpy() instead of the deprecated strcpy().

No functional changes intended.

---

 arch/alpha/kernel/core_marvel.c |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
arch/alpha/kernel/core_marvel.c renamed from arch/alpha/kernel/core_marvel.c~alpha-replace-sprintf-strcpy-with-scnprintf-strscpy +7 -4
@@ -17,6 +17,7 @@
 #include <linux/vmalloc.h>
 #include <linux/mc146818rtc.h>
 #include <linux/rtc.h>
+#include <linux/string.h>
 #include <linux/module.h>
 #include <linux/memblock.h>
 
@@ -79,10 +80,12 @@ mk_resource_name(int pe, int port, char
 {
 	char tmp[80];
 	char *name;
-	
-	sprintf(tmp, "PCI %s PE %d PORT %d", str, pe, port);
-	name = memblock_alloc_or_panic(strlen(tmp) + 1, SMP_CACHE_BYTES);
-	strcpy(name, tmp);
+	size_t sz;
+
+	sz = scnprintf(tmp, sizeof(tmp), "PCI %s PE %d PORT %d", str, pe, port);
+	sz += 1; /* NUL terminator */
+	name = memblock_alloc_or_panic(sz, SMP_CACHE_BYTES);
+	strscpy(name, tmp, sz);
 
 	return name;
 }

_

Patches currently in -mm which might be from [email protected] are

mm-hugetlb-use-str_plural-in-report_hugepages.patch mm-cma-use-str_plural-in-cma_declare_contiguous_multi.patch