From f097bcb278aeb8f4a85e23f80d38f9cc8dbd65f7 Mon Sep 17 00:00:00 2001 From: Scott Williams Date: Thu, 1 Jun 2017 22:48:41 +0100 Subject: [PATCH] ensure we consume stream when failing to read ICC profile --- src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs b/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs index 13c51db24..d65c095da 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs @@ -982,6 +982,7 @@ namespace ImageSharp.Formats byte[] identifier = new byte[Icclength]; this.InputProcessor.ReadFull(identifier, 0, Icclength); + remaining -= Icclength; // we have read it by this point if (identifier[0] == 'I' && identifier[1] == 'C' && @@ -996,7 +997,6 @@ namespace ImageSharp.Formats identifier[10] == 'E' && identifier[11] == '\0') { - remaining -= Icclength; byte[] profile = new byte[remaining]; this.InputProcessor.ReadFull(profile, 0, remaining); @@ -1009,6 +1009,11 @@ namespace ImageSharp.Formats metadata.IccProfile.Extend(profile); } } + else + { + // not an ICC profile we can handle read the remaining so we can carry on and ignore this. + this.InputProcessor.Skip(remaining); + } } ///