[LTP] [PATCH 3/3] tst_kconfig: Prevent stack buffer overread

Andrea Cervesato andrea.cervesato@suse.de
Tue Oct 6 15:02:39 CEST 2026


From: Andrea Cervesato <andrea.cervesato@suse.com>

kconfig_parse_line() stops scanning value characters only at
whitespace. Because isspace('\0') is false, lines without trailing
whitespace cause an out-of-bounds stack read past the terminating
NUL byte.

Stop scanning when reaching NUL or whitespace.

Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
 lib/tst_kconfig.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/tst_kconfig.c b/lib/tst_kconfig.c
index 49957e28d..f055c2e5f 100644
--- a/lib/tst_kconfig.c
+++ b/lib/tst_kconfig.c
@@ -255,7 +255,7 @@ out:
 		while (isspace(*val))
 			val++;
 
-		while (!isspace(val[val_len]))
+		while (val[val_len] && !isspace(val[val_len]))
 			val_len++;
 
 		if (val_len == 1) {

-- 
2.51.0



More information about the ltp mailing list