Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Commit ec1a57f

Browse files
committed
formats/pktline: fixed underflow glitch reading network stream
1 parent 1cd347e commit ec1a57f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

formats/pktline/decoder.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,12 @@ func (d *Decoder) readLine() (string, error) {
4848
}
4949

5050
line := make([]byte, exp)
51-
if read, err := d.r.Read(line); err != nil {
51+
if read, err := io.ReadFull(d.r, line); err != nil {
52+
if err == io.ErrUnexpectedEOF && read < exp {
53+
return "", ErrUnderflow
54+
}
55+
5256
return "", err
53-
} else if read != exp {
54-
return "", ErrUnderflow
5557
}
5658

5759
return string(line), nil

0 commit comments

Comments
 (0)