* [PATCH] alpha/boot: replace strcpy() with strscpy() when copying envval
@ 2025-12-05 18:03 Kathara Sasikumar
0 siblings, 0 replies; only message in thread
From: Kathara Sasikumar @ 2025-12-05 18:03 UTC (permalink / raw)
To: richard.henderson
Cc: mattst88, linmag7, david.hunter.linux, linux-alpha, linux-kernel,
shuah, skhan, katharasasikumar007
strcpy() does not check the size of the destination buffer and is
deprecated in the kernel as documented in
Documentation/process/deprecated.rst. ZERO_PGE is PAGE_SIZE bytes, so
using strscpy() with PAGE_SIZE makes the copy safe and avoids any risk
of overflow.
No functional change intended.
Signed-off-by: Kathara Sasikumar <katharasasikumar007@gmail.com>
---
arch/alpha/boot/bootp.c | 2 +-
arch/alpha/boot/main.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/alpha/boot/bootp.c b/arch/alpha/boot/bootp.c
index 842e85776cc0..e0b411ded992 100644
--- a/arch/alpha/boot/bootp.c
+++ b/arch/alpha/boot/bootp.c
@@ -204,7 +204,7 @@ start_kernel(void)
load(START_ADDR, START_ADDR+(4*KERNEL_SIZE), KERNEL_SIZE);
memset((char*)ZERO_PGE, 0, PAGE_SIZE);
- strcpy((char*)ZERO_PGE, envval);
+ strscpy((char *)ZERO_PGE, envval, PAGE_SIZE);
#ifdef INITRD_IMAGE_SIZE
((long *)(ZERO_PGE+256))[0] = initrd_start;
((long *)(ZERO_PGE+256))[1] = INITRD_IMAGE_SIZE;
diff --git a/arch/alpha/boot/main.c b/arch/alpha/boot/main.c
index 22a1cb0264af..7ec728c037d8 100644
--- a/arch/alpha/boot/main.c
+++ b/arch/alpha/boot/main.c
@@ -180,7 +180,7 @@ void start_kernel(void)
nbytes = 0;
}
envval[nbytes] = '\0';
- strcpy((char*)ZERO_PGE, envval);
+ strscpy((char *)ZERO_PGE, envval, PAGE_SIZE);
srm_printk(" Ok\nNow booting the kernel\n");
runkernel();
--
2.51.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2025-12-05 18:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-05 18:03 [PATCH] alpha/boot: replace strcpy() with strscpy() when copying envval Kathara Sasikumar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox