If n is 0, then it can indicate one of two scenarios:
This reader has reached its “end of file”…
The buffer specified was 0 bytes in length.
This suggests that it is legal to pass a zero-length buffer to read. However, if a zero-length buffer is passed to libflate::gzip::Decoder::read, then it will pass the buffer to the underlying self.reader, which will of course return zero, setting read_size to zero; then, because read_size is zero, it will set self.eos to true and look for a trailer—something it definitely shouldn’t do in the middle of an input stream.
According to the documentation for the
Read
trait’sread
function:This suggests that it is legal to pass a zero-length buffer to
read
. However, if a zero-length buffer is passed tolibflate::gzip::Decoder::read
, then it will pass the buffer to the underlyingself.reader
, which will of course return zero, settingread_size
to zero; then, becauseread_size
is zero, it will setself.eos
totrue
and look for a trailer—something it definitely shouldn’t do in the middle of an input stream.