From 9372f8fb339838677e5af5ad3a65d686dff82986 Mon Sep 17 00:00:00 2001 From: Charis Zhao Date: Thu, 26 Dec 2019 16:46:02 +0800 Subject: [PATCH] add data size check (#1381) --- src/neo/IO/Helper.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/neo/IO/Helper.cs b/src/neo/IO/Helper.cs index df74602cdd..531ce4827d 100644 --- a/src/neo/IO/Helper.cs +++ b/src/neo/IO/Helper.cs @@ -79,7 +79,8 @@ public static byte[] CompressLz4(this byte[] data) public static byte[] DecompressLz4(this byte[] data, int maxOutput) { - maxOutput = Math.Min(maxOutput, data.Length * 255); + var maxDecompressDataLength = data.Length * 255; + if (maxDecompressDataLength > 0) maxOutput = Math.Min(maxOutput, maxDecompressDataLength); using var buffer = MemoryPool.Shared.Rent(maxOutput); int length = LZ4Codec.Decode(data, buffer.Memory.Span); if (length < 0 || length > maxOutput) throw new FormatException();