alpha: boot: check OSFLAGS length in start_kernel()
PATCH 1/1 alpha: boot: check OSFLAGS length in start_kernel()
bootp.c and bootpz.c reject a length >= sizeof(envval) from callback_getenv() before writing the terminating NUL. main.c only rejects negative values, so a return value of 256 would write one byte past the end of envval.
Use the same check as the other two files. I don't know whether the SRM firmware can actually return a length equal to the buffer size, so this is mainly for consistency. I have not tested on Alpha hardware.
Signed-off-by Mohamed Salem Gorrab <[email protected]>
--- arch/alpha/boot/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/alpha/boot/main.c +1 -1
@@ -176,7 +176,7 @@ void start_kernel(void) } nbytes =callback_getenv (ENV_BOOTED_OSFLAGS , envval,sizeof (envval)); -if (nbytes <0 ) { +if (nbytes <0 || nbytes >=sizeof (envval)) { nbytes =0 ; } envval[nbytes] ='\0' ;
---
base-commit: 4405c18c95d2d0f99f6c581ef0ee8591a1aa6ccd
change-id: 20261119-alpha-osflags-d51e88f028b3
Best regards,
Signature · 1 line
Mohamed Salem Gorrab <[email protected]>