diff --git a/src/ImageSharp/Formats/Jpg/JpegDecoderCore.cs b/src/ImageSharp/Formats/Jpg/JpegDecoderCore.cs index 28bec0d92..2d6e3ee7c 100644 --- a/src/ImageSharp/Formats/Jpg/JpegDecoderCore.cs +++ b/src/ImageSharp/Formats/Jpg/JpegDecoderCore.cs @@ -388,7 +388,7 @@ namespace ImageSharp.Formats this.ProcessApp14Marker(remaining); break; default: - if ((JpegConstants.Markers.APP0 <= marker && marker <= JpegConstants.Markers.APP15) + if ((marker >= JpegConstants.Markers.APP0 && marker <= JpegConstants.Markers.APP15) || marker == JpegConstants.Markers.COM) { this.Skip(remaining); @@ -1488,7 +1488,7 @@ namespace ImageSharp.Formats ah = this.temp[3 + scanComponentCountX2] >> 4; al = this.temp[3 + scanComponentCountX2] & 0x0f; - if ((zigStart == 0 && zigEnd != 0) || zigStart > zigEnd || BlockF.BlockSize <= zigEnd) + if ((zigStart == 0 && zigEnd != 0) || zigStart > zigEnd || zigEnd >= BlockF.BlockSize) { throw new ImageFormatException("Bad spectral selection bounds"); } diff --git a/src/ImageSharp/Formats/Jpg/JpegEncoderCore.cs b/src/ImageSharp/Formats/Jpg/JpegEncoderCore.cs index 2ec65bc5b..3144fdbd3 100644 --- a/src/ImageSharp/Formats/Jpg/JpegEncoderCore.cs +++ b/src/ImageSharp/Formats/Jpg/JpegEncoderCore.cs @@ -31,6 +31,7 @@ namespace ImageSharp.Formats 39, 46, 53, 60, 61, 54, 47, 55, 62, 63, }; +#pragma warning disable SA1118 // ParameterMustNotSpanMultipleLines /// /// The Huffman encoding specifications. /// This encoder uses the same Huffman encoding for all images. @@ -43,7 +44,10 @@ namespace ImageSharp.Formats { 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 }, - new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }), + new byte[] + { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 + }), new HuffmanSpec( new byte[] { @@ -75,7 +79,10 @@ namespace ImageSharp.Formats { 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 }, - new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }), + new byte[] + { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 + }), // Chrominance AC. new HuffmanSpec( @@ -105,6 +112,7 @@ namespace ImageSharp.Formats 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa }) }; +#pragma warning restore SA1118 // ParameterMustNotSpanMultipleLines /// /// The compiled representations of theHuffmanSpec.