Skip to content

Commit

Permalink
Fix two decoding bugs found by go-fuzz
Browse files Browse the repository at this point in the history
(https://github.com/dvyukov/go-fuzz)

- handle negative message-set sizes in FetchResponses
- handle IPv6 and/or malformed broker addresses
  • Loading branch information
eapache committed Aug 26, 2015
1 parent 9dd45b2 commit 306db49
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,10 @@ func (b *Broker) decode(pd packetDecoder) (err error) {
return err
}

b.addr = fmt.Sprint(host, ":", port)
b.addr = net.JoinHostPort(host, fmt.Sprint(port))
if _, _, err := net.SplitHostPort(b.addr); err != nil {
return err
}

return nil
}
Expand Down
3 changes: 3 additions & 0 deletions fetch_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ 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

0 comments on commit 306db49

Please sign in to comment.