Thread (56 messages) 56 messages, 2 authors, 11d ago

[PATCH 19/27] selftests/landlock: Fix off-by-one in regex_escape()

flat view
COOLING11d

From: Günther Noack <hidden>
Date: 2026-10-08 14:27:31
Also in: linux-kselftest, lkml
Subsystem: kernel selftest framework, landlock security module, the rest · Maintainers: Shuah Khan, Shuah Khan, Mickaël Salaün, Linus Torvalds

The final check in regex_escape() was off by one byte
and should require one byte less to put the NUL byte.

Assisted-by: LLM
Signed-off-by: Günther Noack <redacted>
---
 tools/testing/selftests/landlock/common.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/landlock/common.h b/tools/testing/selftests/landlock/common.h
index 91842f618a3a..ae6a0eb8e343 100644
--- a/tools/testing/selftests/landlock/common.h
+++ b/tools/testing/selftests/landlock/common.h
@@ -294,7 +294,7 @@ static __maybe_unused ssize_t regex_escape(const char *const src, char *dst,
 			*d++ = *s;
 		}
 	}
-	if (d >= dst + dst_size - 1)
+	if (d >= dst + dst_size)
 		goto err_nomem;
 
 	*d = '\0';
-- 
2.56.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help