Closed fish98 closed 1 month ago
OK, the code handles read
errors - if we get less than "sizeof(trailer) - tbytes" bytes, that is an error and we abort.
I think the issue is that this and the CRC failure don't call inflateEnd
.
Test this change:
[master 83562f7c7] Make sure we call inflateEnd when there is an error reading or comparing the stream CRC (Issue #91)
Description
The use of uninitialized memory of the trailer array is found in function
cups_fill
ofcups/file.c
. Detailed code can be found below:when
vail_in
is less thansizeof(trailer)
, the operationmemcpy(trailer, fp->stream.next_in, (size_t)tbytes);
will end up with uninitialized value intrailer
array. The subsequent functionif (read(fp->fd, trailer + tbytes, sizeof(trailer) - (size_t)tbytes) < ((ssize_t)sizeof(trailer) - tbytes))
may also inroduce unitialized value issue whenread()
function returnsEOF
or error.Suggested Fix
unsigned char trailer[8] = {0};
read()
errorPostscript
The issue is identified by OSS-Fuzz harness
fuzzipp
with MSAN. Here is the linked issue.