public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] mmap01: initialize buffer in check_file()
@ 2025-01-22 10:09 Sven Schnelle
  2025-01-22 10:26 ` Petr Vorel
  2025-01-22 10:43 ` Ricardo B. Marliere via ltp
  0 siblings, 2 replies; 7+ messages in thread
From: Sven Schnelle @ 2025-01-22 10:09 UTC (permalink / raw)
  To: ltp

mmap01 reported random test failures. Turns out the
the temporary buffer in check_file() isn't initialized.
The SAFE_READ reads less then sizeof(buf) bytes so the
rest stays initialized and might contain bytes check_file()
is looking for.

Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
---
 testcases/kernel/syscalls/mmap/mmap01.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/testcases/kernel/syscalls/mmap/mmap01.c b/testcases/kernel/syscalls/mmap/mmap01.c
index c93c37ceda52..ff09bc635c74 100644
--- a/testcases/kernel/syscalls/mmap/mmap01.c
+++ b/testcases/kernel/syscalls/mmap/mmap01.c
@@ -36,6 +36,7 @@ static void check_file(void)
 	int i, fildes, buf_len = sizeof(STRING) + 3;
 	char buf[buf_len];
 
+	memset(buf, 0, sizeof(buf));
 	fildes = SAFE_OPEN(TEMPFILE, O_RDONLY);
 	SAFE_READ(0, fildes, buf, sizeof(buf));
 
-- 
2.47.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-01-22 12:33 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-22 10:09 [LTP] [PATCH] mmap01: initialize buffer in check_file() Sven Schnelle
2025-01-22 10:26 ` Petr Vorel
2025-01-22 11:01   ` Cyril Hrubis
2025-01-22 12:13     ` Sven Schnelle
2025-01-22 12:28       ` Cyril Hrubis
2025-01-22 12:33         ` Sven Schnelle
2025-01-22 10:43 ` Ricardo B. Marliere via ltp

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox