network: don't allocate memory for messages larger than PayloadMaxSize
This commit is contained in:
parent
39fd799992
commit
8388e509df
1 changed files with 3 additions and 3 deletions
|
@ -103,14 +103,14 @@ func (m *Message) Decode(br *io.BinReader) error {
|
|||
m.Payload = payload.NewNullPayload()
|
||||
return nil
|
||||
}
|
||||
if l > PayloadMaxSize {
|
||||
return errors.New("invalid payload size")
|
||||
}
|
||||
m.compressedPayload = make([]byte, l)
|
||||
br.ReadBytes(m.compressedPayload)
|
||||
if br.Err != nil {
|
||||
return br.Err
|
||||
}
|
||||
if len(m.compressedPayload) > PayloadMaxSize {
|
||||
return errors.New("invalid payload size")
|
||||
}
|
||||
return m.decodePayload()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue