Skip to content

Commit

Permalink
fix parse frame with negative frame size
Browse files Browse the repository at this point in the history
  • Loading branch information
Zariel committed May 2, 2015
1 parent 5483158 commit 332853a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions frame.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,10 @@ func (f *framer) trace() {

// reads a frame form the wire into the framers buffer
func (f *framer) readFrame(head *frameHeader) error {
if head.length < 0 {
return fmt.Errorf("frame body length can not be less than 0: %d", head.length)
}

if cap(f.readBuffer) >= head.length {
f.rbuf = f.readBuffer[:head.length]
} else {
Expand Down

0 comments on commit 332853a

Please sign in to comment.