Skip to content

Commit

Permalink
Merge pull request #267 from andyxning/pre_check_for_msg_size
Browse files Browse the repository at this point in the history
check response message size is positive
  • Loading branch information
ploxiln authored Sep 26, 2019
2 parents 61f49c0 + 82f8d10 commit 0455293
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
language: go
go:
- 1.10.x
- 1.11.x
- 1.12.x
- 1.13.x
env:
- NSQ_DOWNLOAD=nsq-0.3.8.linux-amd64.go1.6.2 GOARCH=amd64
- NSQ_DOWNLOAD=nsq-0.3.8.linux-amd64.go1.6.2 GOARCH=386
Expand Down
4 changes: 4 additions & 0 deletions protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package nsq
import (
"encoding/binary"
"errors"
"fmt"
"io"
"regexp"
)
Expand Down Expand Up @@ -56,6 +57,9 @@ func ReadResponse(r io.Reader) ([]byte, error) {
return nil, err
}

if msgSize < 0 {
return nil, fmt.Errorf("response msg size is negative: %v", msgSize)
}
// message binary data
buf := make([]byte, msgSize)
_, err = io.ReadFull(r, buf)
Expand Down

0 comments on commit 0455293

Please sign in to comment.