aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-05-19 13:02:29 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2016-05-19 13:13:47 +0200
commitec1a57f40f78ed5209cdcc7efbadc8d004716b2d (patch)
treeb52a1ea6852df0a67e19c2c49e5c47b823c0cb5f
parent1cd347ec8970388f83745c9a530ea2bcd705c6d9 (diff)
downloadgo-git-ec1a57f40f78ed5209cdcc7efbadc8d004716b2d.tar.gz
formats/pktline: fixed underflow glitch reading network stream
-rw-r--r--formats/pktline/decoder.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/formats/pktline/decoder.go b/formats/pktline/decoder.go
index a078475..c30be6b 100644
--- a/formats/pktline/decoder.go
+++ b/formats/pktline/decoder.go
@@ -48,10 +48,12 @@ func (d *Decoder) readLine() (string, error) {
}
line := make([]byte, exp)
- if read, err := d.r.Read(line); err != nil {
+ if read, err := io.ReadFull(d.r, line); err != nil {
+ if err == io.ErrUnexpectedEOF && read < exp {
+ return "", ErrUnderflow
+ }
+
return "", err
- } else if read != exp {
- return "", ErrUnderflow
}
return string(line), nil