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

Centralize and unify getSubset error checking #525

Merged
merged 1 commit into from
Aug 27, 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
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