Merge pull request #1255 from nspcc-dev/p2p-handle-decompression-length-mismatch

network: handle length mismatch in decompression routine
This commit is contained in:
Roman Khimov 2020-08-04 10:24:57 +03:00 committed by GitHub
commit 3e192b11b2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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
} }