Skip to content

Commit 692e244

Browse files
Fix #937 (#938)
1 parent a842e98 commit 692e244

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

src/ImageSharp/Formats/Png/Zlib/ZlibInflateStream.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Six Labors and contributors.
1+
// Copyright (c) Six Labors and contributors.
22
// Licensed under the Apache License, Version 2.0.
33

44
using System;
@@ -140,7 +140,7 @@ public override int Read(byte[] buffer, int offset, int count)
140140

141141
offset += bytesRead;
142142

143-
if (offset >= length)
143+
if (offset >= length || offset >= count)
144144
{
145145
return bytesRead;
146146
}
@@ -249,4 +249,4 @@ private void InitializeInflateStream()
249249
this.compressedStream = new DeflateStream(this, CompressionMode.Decompress, true);
250250
}
251251
}
252-
}
252+
}

tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Six Labors and contributors.
1+
// Copyright (c) Six Labors and contributors.
22
// Licensed under the Apache License, Version 2.0.
33

44
// ReSharper disable InconsistentNaming
@@ -42,7 +42,8 @@ public partial class PngDecoderTests
4242
TestImages.Png.Rgb24BppTrans,
4343
TestImages.Png.GrayAlpha8Bit,
4444
TestImages.Png.Gray1BitTrans,
45-
TestImages.Png.Bad.ZlibOverflow
45+
TestImages.Png.Bad.ZlibOverflow,
46+
TestImages.Png.Bad.ZlibOverflow2
4647
};
4748

4849
public static readonly string[] TestImages48Bpp =
@@ -294,4 +295,4 @@ public void Identify_VerifyRatio(string imagePath, int xResolution, int yResolut
294295
}
295296
}
296297
}
297-
}
298+
}

tests/ImageSharp.Tests/TestImages.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ public static class Bad
8787
public const string ChunkLength2 = "Png/chunklength2.png";
8888
public const string CorruptedChunk = "Png/big-corrupted-chunk.png";
8989
public const string ZlibOverflow = "Png/zlib-overflow.png";
90+
public const string ZlibOverflow2 = "Png/zlib-overflow2.png";
9091
}
9192

9293
public static readonly string[] All =
16.5 KB
Loading

0 commit comments

Comments
 (0)