[PATCH 20/27] selftests/landlock: Fix the snprintf() error check in matches_log_fs_extra()

From: Günther Noack

Date: Thu Oct 08 2026 - 10:30:09 EST


By storing the snprintf result in a size_t, the chunk_len < 0 check
could never be true. Store it in an int instead, matching the return
type of snprintf().

Fixes: 316d06b01130 ("selftests/landlock: Add audit tests for filesystem")
Assisted-by: LLM
Signed-off-by: Günther Noack <gnoack3000@xxxxxxxxx>
---
tools/testing/selftests/landlock/fs_test.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/landlock/fs_test.c b/tools/testing/selftests/landlock/fs_test.c
index 9abc2adef79d..90f63af1d64d 100644
--- a/tools/testing/selftests/landlock/fs_test.c
+++ b/tools/testing/selftests/landlock/fs_test.c
@@ -7453,7 +7453,7 @@ static int matches_log_fs_extra(struct __test_metadata *const _metadata,
(extra ? strlen(extra) : 0) + 1;
char log_match[log_match_remaining];
char *log_match_cursor = log_match;
- size_t chunk_len;
+ int chunk_len;
ssize_t escaped_len;

chunk_len = snprintf(log_match_cursor, log_match_remaining,
--
2.56.0