network: handle length mismatch in decompression routine

It's a protocol level error when uncompressed payload size doesn't match the
one specified in the header.
This commit is contained in:
Roman Khimov 2020-08-03 22:38:55 +03:00
parent c114c4dd1c
commit 1f46f73d12

View file

@ -30,5 +30,8 @@ func decompress(source []byte) ([]byte, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
return dest[:size], nil if uint32(size) != length {
return nil, errors.New("decompressed payload size doesn't match header")
}
return dest, nil
} }