Skip to content

Commit

Permalink
Merge pull request #525 from Shopify/another-fuzz-fix
Browse files Browse the repository at this point in the history
Centralize and unify getSubset error checking
  • Loading branch information
wvanbergen committed Aug 27, 2015
2 parents 28da351 + 900e4f4 commit 758ae7d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 7 deletions.
3 changes: 0 additions & 3 deletions fetch_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ func (pr *FetchResponseBlock) decode(pd packetDecoder) (err error) {
if err != nil {
return err
}
if msgSetSize < 0 {
return PacketDecodingError{"invalid message set size"}
}

msgSetDecoder, err := pd.getSubset(int(msgSetSize))
if err != nil {
Expand Down
3 changes: 0 additions & 3 deletions produce_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,6 @@ func (p *ProduceRequest) decode(pd packetDecoder) error {
if err != nil {
return err
}
if messageSetSize == 0 {
continue
}
msgSetDecoder, err := pd.getSubset(int(messageSetSize))
if err != nil {
return err
Expand Down
4 changes: 3 additions & 1 deletion real_decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,9 @@ func (rd *realDecoder) remaining() int {
}

func (rd *realDecoder) getSubset(length int) (packetDecoder, error) {
if length > rd.remaining() {
if length < 0 {
return nil, PacketDecodingError{"invalid subset size"}
} else if length > rd.remaining() {
rd.off = len(rd.raw)
return nil, ErrInsufficientData
}
Expand Down

0 comments on commit 758ae7d

Please sign in to comment.