From d4bc391f29f0b237f60d805e6806f454b0073d6a Mon Sep 17 00:00:00 2001 From: Andrzej Popowski Date: Mon, 4 May 2015 10:45:50 +0200 Subject: [PATCH] [exif] - Updated the codes fixing a prevent issue for error handling from slp Change-Id: I4181d0af91035ed358c8eb2335c1acb099d2fcfa Signed-off-by: Andrzej Popowski --- src/exif/jpeg_file.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/exif/jpeg_file.cc b/src/exif/jpeg_file.cc index 8570eee9..168575a0 100644 --- a/src/exif/jpeg_file.cc +++ b/src/exif/jpeg_file.cc @@ -148,7 +148,14 @@ PlatformResult JpegFile::load(const std::string& path) { } fseek(m_in_file, 0, SEEK_END); - const std::size_t in_file_size = static_cast(ftell(m_in_file)); + + long ftell_val = ftell(m_in_file); + if (0 > ftell_val) { + LoggerE("Input file [%s] access error! [%d]", path.c_str(), errno); + return PlatformResult(ErrorCode::UNKNOWN_ERR, "JPEG file is invalid"); + } + + const std::size_t in_file_size = static_cast(ftell_val); fseek(m_in_file, 0, SEEK_SET); LoggerD("JPEG file: [%s] size:%d", path.c_str(), in_file_size); if (0 == in_file_size) { -- 2.34.1