Browse Source

Fix #937 (#938)

af/merge-core
James Jackson-South 7 years ago
committed by GitHub
parent
commit
d5d69d0bdc
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      src/ImageSharp/Formats/Png/Zlib/ZlibInflateStream.cs
  2. 7
      tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs
  3. 1
      tests/ImageSharp.Tests/TestImages.cs
  4. 3
      tests/Images/Input/Png/zlib-overflow2.png

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

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
@ -140,7 +140,7 @@ namespace SixLabors.ImageSharp.Formats.Png.Zlib
offset += bytesRead;
if (offset >= length)
if (offset >= length || offset >= count)
{
return bytesRead;
}
@ -249,4 +249,4 @@ namespace SixLabors.ImageSharp.Formats.Png.Zlib
this.compressedStream = new DeflateStream(this, CompressionMode.Decompress, true);
}
}
}
}

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

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
// ReSharper disable InconsistentNaming
@ -42,7 +42,8 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png
TestImages.Png.Rgb24BppTrans,
TestImages.Png.GrayAlpha8Bit,
TestImages.Png.Gray1BitTrans,
TestImages.Png.Bad.ZlibOverflow
TestImages.Png.Bad.ZlibOverflow,
TestImages.Png.Bad.ZlibOverflow2
};
public static readonly string[] TestImages48Bpp =
@ -294,4 +295,4 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png
}
}
}
}
}

1
tests/ImageSharp.Tests/TestImages.cs

@ -87,6 +87,7 @@ namespace SixLabors.ImageSharp.Tests
public const string ChunkLength2 = "Png/chunklength2.png";
public const string CorruptedChunk = "Png/big-corrupted-chunk.png";
public const string ZlibOverflow = "Png/zlib-overflow.png";
public const string ZlibOverflow2 = "Png/zlib-overflow2.png";
}
public static readonly string[] All =

3
tests/Images/Input/Png/zlib-overflow2.png

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:3994ef9f044fd589a412409b35cf23d346da43af0d82e25f2c11a36b464c7599
size 16887
Loading…
Cancel
Save