Explorar el Código

fix parse frame with negative frame size

Chris Bannister hace 10 años
padre
commit
332853ab7b
Se han modificado 1 ficheros con 4 adiciones y 0 borrados
  1. 4 0
      frame.go

+ 4 - 0
frame.go

@@ -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 {