[LTP] [PATCH] mmap01: initialize buffer in check_file()
Ricardo B. Marliere
rbm@suse.com
Wed Jan 22 11:43:14 CET 2025
On Wed Jan 22, 2025 at 7:09 AM -03, Sven Schnelle wrote:
> 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>
Reviewed-by: Ricardo B. Marliere <rbm@suse.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));
>
More information about the ltp
mailing list