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

From
Günther Noack <hidden>
Date
2026-11-04 21:09:40
Also in
linux-kselftest, lkml
Reply to
Günther Noack, 2026-11-04
The final check in regex_escape() was off by one byte
and should require one byte less to put the NUL byte.

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 dcfdcfecde86..0df8ae88d4fa 100644
--- a/tools/testing/selftests/landlock/common.h
+++ b/tools/testing/selftests/landlock/common.h
@@ -307,7 +307,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
Thread (55 messages) 55 messages, 2 authors, last reply 4d ago
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help