From 91d8405e52c186af90a0f8df9c0a147925552bc2 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Tue, 12 Jul 2016 16:01:12 +0300 Subject: [PATCH] stop search of markers in Exif reader to prevent infinite loop --- modules/imgcodecs/src/jpeg_exif.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/imgcodecs/src/jpeg_exif.cpp b/modules/imgcodecs/src/jpeg_exif.cpp index adb87e5b77..0704c2f49a 100644 --- a/modules/imgcodecs/src/jpeg_exif.cpp +++ b/modules/imgcodecs/src/jpeg_exif.cpp @@ -140,8 +140,8 @@ std::map ExifReader::getExif() return m_exif; //Until this moment the map is empty } - bool exifFound = false; - while( ( !feof( f ) ) && !exifFound ) + bool exifFound = false, stopSearch = false; + while( ( !feof( f ) ) && !exifFound && !stopSearch ) { count = fread( appMarker, sizeof(unsigned char), markerSize, f ); if( count < markerSize ) @@ -180,6 +180,7 @@ std::map ExifReader::getExif() break; default: //No other markers are expected according to standard. May be a signal of error + stopSearch = true; break; } }