Skip to content

Commit

Permalink
add data size check (neo-project#1381)
Browse files Browse the repository at this point in the history
  • Loading branch information
eryeer authored and Tommo-L committed Jun 22, 2020
1 parent b167c2a commit 9372f8f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/neo/IO/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<byte>.Shared.Rent(maxOutput);
int length = LZ4Codec.Decode(data, buffer.Memory.Span);
if (length < 0 || length > maxOutput) throw new FormatException();
Expand Down

0 comments on commit 9372f8f

Please sign in to comment.