Browse Source

Santize descriptor bounds. Fixes #1530

pull/1554/head
James Jackson-South 5 years ago
parent
commit
f1a8e6e763
  1. 3
      src/ImageSharp/Formats/Gif/GifDecoderCore.cs
  2. 12
      tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs
  3. 1
      tests/ImageSharp.Tests/TestImages.cs
  4. 2
      tests/Images/External
  5. 3
      tests/Images/Input/Gif/issues/issue1530.gif

3
src/ImageSharp/Formats/Gif/GifDecoderCore.cs

@ -535,7 +535,8 @@ namespace SixLabors.ImageSharp.Formats.Gif
return; return;
} }
Buffer2DRegion<TPixel> pixelRegion = frame.PixelBuffer.GetRegion(this.restoreArea.Value); var interest = Rectangle.Intersect(frame.Bounds(), this.restoreArea.Value);
Buffer2DRegion<TPixel> pixelRegion = frame.PixelBuffer.GetRegion(interest);
pixelRegion.Clear(); pixelRegion.Clear();
this.restoreArea = null; this.restoreArea = null;

12
tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs

@ -171,6 +171,17 @@ namespace SixLabors.ImageSharp.Tests.Formats.Gif
} }
} }
// https://github.com/SixLabors/ImageSharp/issues/1503
[Theory]
[WithFile(TestImages.Gif.Issues.Issue1530, PixelTypes.Rgba32)]
public void Issue1530_BadDescriptorDimensions<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{
using Image<TPixel> image = provider.GetImage();
image.DebugSaveMultiFrame(provider);
image.CompareToReferenceOutputMultiFrame(provider, ImageComparer.Exact);
}
// https://github.com/SixLabors/ImageSharp/issues/405 // https://github.com/SixLabors/ImageSharp/issues/405
[Theory] [Theory]
[WithFile(TestImages.Gif.Issues.BadAppExtLength, PixelTypes.Rgba32)] [WithFile(TestImages.Gif.Issues.BadAppExtLength, PixelTypes.Rgba32)]
@ -181,6 +192,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Gif
using (Image<TPixel> image = provider.GetImage()) using (Image<TPixel> image = provider.GetImage())
{ {
image.DebugSave(provider); image.DebugSave(provider);
image.CompareFirstFrameToReferenceOutput(ImageComparer.Exact, provider); image.CompareFirstFrameToReferenceOutput(ImageComparer.Exact, provider);
} }
} }

1
tests/ImageSharp.Tests/TestImages.cs

@ -416,6 +416,7 @@ namespace SixLabors.ImageSharp.Tests
public const string BadAppExtLength_2 = "Gif/issues/issue405_badappextlength252-2.gif"; public const string BadAppExtLength_2 = "Gif/issues/issue405_badappextlength252-2.gif";
public const string BadDescriptorWidth = "Gif/issues/issue403_baddescriptorwidth.gif"; public const string BadDescriptorWidth = "Gif/issues/issue403_baddescriptorwidth.gif";
public const string Issue1505 = "Gif/issues/issue1505_argumentoutofrange.png"; public const string Issue1505 = "Gif/issues/issue1505_argumentoutofrange.png";
public const string Issue1530 = "Gif/issues/issue1530.gif";
} }
public static readonly string[] All = { Rings, Giphy, Cheers, Trans, Kumin, Leo, Ratio4x1, Ratio1x4 }; public static readonly string[] All = { Rings, Giphy, Cheers, Trans, Kumin, Leo, Ratio4x1, Ratio1x4 };

2
tests/Images/External

@ -1 +1 @@
Subproject commit 346070e5ba538f1a3bbafc0ea7367404c5f8c9ab Subproject commit 1df65162448996332449387a46da942e181043c8

3
tests/Images/Input/Gif/issues/issue1530.gif

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