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

Günther Noack gnoack3000 at gmail.com
Thu Oct 8 14:25:48 UTC 2026


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 <gnoack3000 at gmail.com>
---
 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




More information about the Linux-security-module-archive mailing list