Browse Source

Merge pull request from GHSA-x462-89pf-6r5h

Jakob Borg 4 years ago
parent
commit
fb4fdaf4c0
1 changed files with 4 additions and 0 deletions
  1. 4 0
      lib/relay/protocol/protocol.go

+ 4 - 0
lib/relay/protocol/protocol.go

@@ -4,6 +4,7 @@ package protocol
 
 import (
 	"errors"
+	"fmt"
 	"io"
 )
 
@@ -86,6 +87,9 @@ func ReadMessage(r io.Reader) (interface{}, error) {
 	if header.magic != magic {
 		return nil, errors.New("magic mismatch")
 	}
+	if header.messageLength < 0 || header.messageLength > 1024 {
+		return nil, fmt.Errorf("bad length (%d)", header.messageLength)
+	}
 
 	buf = make([]byte, int(header.messageLength))
 	if _, err := io.ReadFull(r, buf); err != nil {