mirror of
https://github.com/itzg/mc-router.git
synced 2024-11-21 11:25:41 +01:00
Prevent crash due to large memory allocation (#291)
This commit is contained in:
parent
09ed21d467
commit
f34b6e85b0
@ -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).
|
||||
|
Loading…
Reference in New Issue
Block a user