Skip to content

Commit

Permalink
Centralize and unify getSubset error checking
Browse files Browse the repository at this point in the history
The fix in #523 did not cover all cases, as found by subsequent go-fuzz runs.
  • Loading branch information
eapache committed Aug 27, 2015
1 parent 6902717 commit 900e4f4
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 900e4f4

Please sign in to comment.