Skip to content

Commit

Permalink
Prevent crash due to large memory allocation (#291)
Browse files Browse the repository at this point in the history
  • Loading branch information
serverwentdown authored May 6, 2024
1 parent 09ed21d commit f34b6e8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions mcproto/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,12 @@ func ReadFrame(reader io.Reader, addr net.Addr) (*Frame, error) {
if err != nil {
return nil, err
}

// Limit frame length to 2^21 - 1
if frame.Length > 2097151 {
return nil, errors.Errorf("frame length %d too large", frame.Length)
}

logrus.
WithField("client", addr).
WithField("length", frame.Length).
Expand Down

0 comments on commit f34b6e8

Please sign in to comment.