Browse Source
Merge pull request #801 from jongleur1983/797-LoadThrowsNRE-bySharpFuzz
#797 throw ImageFormatException when no StartOfFrame marker is found
af/merge-core
James Jackson-South
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
17 additions and
0 deletions
-
src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs
-
tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Baseline.cs
-
tests/ImageSharp.Tests/TestImages.cs
-
tests/Images/Input/Jpg/issues/Issue797-InvalidImage.jpg
|
|
|
@ -859,6 +859,11 @@ namespace SixLabors.ImageSharp.Formats.Jpeg |
|
|
|
/// </summary>
|
|
|
|
private void ProcessStartOfScanMarker() |
|
|
|
{ |
|
|
|
if (this.Frame is null) |
|
|
|
{ |
|
|
|
throw new ImageFormatException("No readable SOFn (Start Of Frame) marker found."); |
|
|
|
} |
|
|
|
|
|
|
|
int selectorsCount = this.InputStream.ReadByte(); |
|
|
|
for (int i = 0; i < selectorsCount; i++) |
|
|
|
{ |
|
|
|
|
|
|
|
@ -42,5 +42,13 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg |
|
|
|
// TODO: We need a public ImageDecoderException class in ImageSharp!
|
|
|
|
Assert.ThrowsAny<Exception>(() => provider.GetImage(JpegDecoder)); |
|
|
|
} |
|
|
|
|
|
|
|
[Theory] |
|
|
|
[WithFile(TestImages.Jpeg.Issues.InvalidJpegThrowsWrongException797, PixelTypes.Rgba32)] |
|
|
|
public void LoadingImage_InvalidTagLength_ShouldThrow<TPixel>(TestImageProvider<TPixel> provider) |
|
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
|
{ |
|
|
|
Assert.Throws<ImageFormatException>(() => provider.GetImage()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -167,6 +167,7 @@ namespace SixLabors.ImageSharp.Tests |
|
|
|
public const string OrderedInterleavedProgressive723C = "Jpg/issues/Issue723-Ordered-Interleaved-Progressive-C.jpg"; |
|
|
|
public const string ExifGetString750Transform = "Jpg/issues/issue750-exif-tranform.jpg"; |
|
|
|
public const string ExifGetString750Load = "Jpg/issues/issue750-exif-load.jpg"; |
|
|
|
public const string InvalidJpegThrowsWrongException797 = "Jpg/issues/Issue797-InvalidImage.jpg"; |
|
|
|
} |
|
|
|
|
|
|
|
public static readonly string[] All = Baseline.All.Concat(Progressive.All).ToArray(); |
|
|
|
|
|
|
|
@ -0,0 +1,3 @@ |
|
|
|
version https://git-lfs.github.com/spec/v1 |
|
|
|
oid sha256:2c3c6a09c1ed868bb18c7c5038da743a88dbfd10762a2b12260053adf63b376f |
|
|
|
size 381 |