[LTP] [PATCH] mmap01: initialize buffer in check_file()
Sven Schnelle
svens@linux.ibm.com
Wed Jan 22 13:33:33 CET 2025
Cyril Hrubis <chrubis@suse.cz> writes:
> Hi!
>> >> > 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.
>> >>
>> >> Looks reasonable to me.
>> >> Reviewed-by: Petr Vorel <pvorel@suse.cz>
>> >>
>> >> @Cyril a candidate for merge before the release.
>> >
>> > Alternatively we could use the return value from the SAFE_READ() instead
>> > of the buf_len. Also I suppose that we could check that we read at least
>> > something.
>>
>> I wonder whether a check that strlen(STRING) bytes was read is
>> sufficient, and if it's more just FAIL the test? My understanding of the
>> test is that the data written beyond file's end isn't yet synced, so
>> if we can read more bytes that would already be an error?
>
> I would say yes, but it does not hurt to keep the check that the file
> data were not corrupted by the write after the file end. So maybe we
> just need to:
>
> 1. check that we read right size
> 2. check that the buffer has correct bytes
Ok. I'll change the patch and send a V2 later.
More information about the ltp
mailing list