Skip to content

Commit

Permalink
check response message size is positive
Browse files Browse the repository at this point in the history
  • Loading branch information
andyxning committed Sep 26, 2019
1 parent 61f49c0 commit 9f320ad
Showing 1 changed file with 4 additions and 0 deletions.
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 9f320ad

Please sign in to comment.