From 1f46f73d1231ce03dffefb61402ca773b7e524f9 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Mon, 3 Aug 2020 22:38:55 +0300 Subject: [PATCH] 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. --- pkg/network/compress.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/network/compress.go b/pkg/network/compress.go index 993b2aac0..a8e73915d 100644 --- a/pkg/network/compress.go +++ b/pkg/network/compress.go @@ -30,5 +30,8 @@ func decompress(source []byte) ([]byte, error) { if err != nil { 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 }