Browse Source

Remove obsolete checks and limit horizontal factor. Fix #1076

pull/1078/head
James Jackson-South 6 years ago
parent
commit
0c043e1b9b
  1. 11
      src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegComponent.cs
  2. 2
      src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs

11
src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegComponent.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;
@ -22,11 +22,8 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder
this.Frame = frame;
this.Id = id;
// Valid sampling factors are 1..2
if (horizontalFactor == 0
|| verticalFactor == 0
|| horizontalFactor > 2
|| verticalFactor > 2)
// Validate sampling factors.
if (horizontalFactor == 0 || verticalFactor == 0)
{
JpegThrowHelper.ThrowBadSampling();
}
@ -138,4 +135,4 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder
this.SpectralBlocks = this.memoryAllocator.Allocate2D<Block8x8>(width, height, AllocationOptions.Clean);
}
}
}
}

2
src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs

@ -764,7 +764,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
for (int i = 0; i < this.ComponentCount; i++)
{
byte hv = this.temp[index + 1];
int h = hv >> 4;
int h = (hv >> 4) & 15;
int v = hv & 15;
if (maxH < h)

Loading…
Cancel
Save