[PATCH v2 04/27] selftests/landlock: Zero-initialize the buffer in inconsistent_attr

From: Günther Noack

Date: Wed Nov 04 2026 - 19:30:14 EST


This buffer is passed to landlock_create_ruleset() a bit further down,
expecting an ENOMSG error. This is only guaranteed when the buffer is
zero-initialized.

Signed-off-by: Günther Noack <gnoack3000@xxxxxxxxx>
---
tools/testing/selftests/landlock/base_test.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/landlock/base_test.c b/tools/testing/selftests/landlock/base_test.c
index 89c0d96607de..0bf8632b725f 100644
--- a/tools/testing/selftests/landlock/base_test.c
+++ b/tools/testing/selftests/landlock/base_test.c
@@ -25,7 +25,7 @@
TEST(inconsistent_attr)
{
const long page_size = sysconf(_SC_PAGESIZE);
- char *const buf = malloc(page_size + 1);
+ char *const buf = calloc(1, page_size + 1);
struct landlock_ruleset_attr *const ruleset_attr = (void *)buf;

ASSERT_NE(NULL, buf);

--
2.56.0