libflate::gzip::Decoder::read does not handle zero-length buffer properly
Hawk777 opened this issue · comments
According to the documentation for the Read
trait’s read
function:
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.
Thank you for creating this issue.
Your comment sounds right. I'll fix the problem when I have time (maybe this or next weekend).
Fixed in #62. Thanks again for reporting this issue.