alpha/boot: replace strcpy() with strscpy() when copying envval
PATCH 1/1 alpha/boot: replace strcpy() with strscpy() when copying envval
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 <[email protected]>
--- arch/alpha/boot/bootp.c | 2 +- arch/alpha/boot/main.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/alpha/boot/bootp.c +1 -1
@@ -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 ;
arch/alpha/boot/main.c +1 -1
@@ -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 ();
Signature · 1 line
2.51.0