From e69253a4fb613ddbc5797c9f4828cd9200f64777 Mon Sep 17 00:00:00 2001 From: guoxuedong Date: Thu, 24 Nov 2016 11:08:11 +0800 Subject: [PATCH] Update exif.cpp ExifReader::getExif may enter infinite loop with jpeg image which have no EOI. For example, bytesToSkip may be set to 0 and fseek seems like fseek(f, -2 , SEEK_CUR) for image that end with RST7(FF D7) instead of EOI. --- modules/imgcodecs/src/exif.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/imgcodecs/src/exif.cpp b/modules/imgcodecs/src/exif.cpp index 2708481..8a4f3f4 100644 --- a/modules/imgcodecs/src/exif.cpp +++ b/modules/imgcodecs/src/exif.cpp @@ -160,6 +160,10 @@ std::map ExifReader::getExif() case APP9: case APP10: case APP11: case APP12: case APP13: case APP14: case APP15: case COM: bytesToSkip = getFieldSize( f ); + if (bytesToSkip < markerSize) { + fclose(f); + throw ExifParsingError(); + } fseek( f, static_cast( bytesToSkip - markerSize ), SEEK_CUR ); break; -- 2.7.4