rlp: handle case of normal EOF in Stream.readFull (#22336)
io.Reader may return n > 0 and io.EOF at the end of the input stream. readFull did not handle this correctly, looking only at the error. This fixes it to check for n == len(buf) as well.
This commit is contained in:
@ -952,7 +952,13 @@ func (s *Stream) readFull(buf []byte) (err error) {
|
||||
n += nn
|
||||
}
|
||||
if err == io.EOF {
|
||||
err = io.ErrUnexpectedEOF
|
||||
if n < len(buf) {
|
||||
err = io.ErrUnexpectedEOF
|
||||
} else {
|
||||
// Readers are allowed to give EOF even though the read succeeded.
|
||||
// In such cases, we discard the EOF, like io.ReadFull() does.
|
||||
err = nil
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
Reference in New Issue
Block a user