[exif] - Updated the codes fixing a prevent issue for error handling from slp
authorAndrzej Popowski <a.popowski@samsung.com>
Mon, 4 May 2015 08:45:50 +0000 (10:45 +0200)
committerPawel Andruszkiewicz <p.andruszkie@samsung.com>
Mon, 4 May 2015 09:00:26 +0000 (18:00 +0900)
Change-Id: I4181d0af91035ed358c8eb2335c1acb099d2fcfa
Signed-off-by: Andrzej Popowski <a.popowski@samsung.com>
src/exif/jpeg_file.cc

index 8570eee9756d3c7df7d1a301c882908b03ed675b..168575a0e2b185595e7ebe506b77309e1a8d3487 100644 (file)
@@ -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<size_t>(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<size_t>(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) {