Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix two decoding bugs found by go-fuzz #523

Merged
merged 1 commit into from
Aug 26, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this was because of a hostname with a colon in it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and hostnames with [ in them and \0 and all sorts of other interesting garbage that go-fuzz generated


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