From 4e6fb1776bdcf89acd7394403fa9c32465867b7d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Piotr=20Kosko/Native/Web=20API=20=28SWP=29=20/SRPOL/Profess?= =?utf8?q?ional/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Wed, 16 Jan 2019 09:45:10 +0100 Subject: [PATCH] [Archive][Exif] Added checking return value of fseek MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit SVACE issues: 246302, 246317 Change-Id: If4f803b9db18c352912290b25df706a21cd07853 Signed-off-by: Piotr Kosko/Native/Web API (SWP) /SRPOL/Professional/삼성전자 --- src/archive/zip_add_request.cc | 9 +++++++-- src/exif/jpeg_file.cc | 7 ++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/archive/zip_add_request.cc b/src/archive/zip_add_request.cc index d6e862f3..583bfead 100644 --- a/src/archive/zip_add_request.cc +++ b/src/archive/zip_add_request.cc @@ -358,9 +358,14 @@ PlatformResult ZipAddRequest::addToZipArchive(filesystem::NodePtr src_file_node) } // Get file length - fseek(m_input_file, 0, SEEK_END); + int res = fseek(m_input_file, 0, SEEK_END); + if (0 != res) { + return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Reading input file failed", + ("fseek failed with error! [%d]", res)); + } + const size_t in_file_size = ftell(m_input_file); - int res = fseek(m_input_file, 0, SEEK_SET); + res = fseek(m_input_file, 0, SEEK_SET); if (0 != res) { return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Reading input file failed", ("fseek failed with error! [%d]", res)); diff --git a/src/exif/jpeg_file.cc b/src/exif/jpeg_file.cc index 39bf00c7..a391e73f 100644 --- a/src/exif/jpeg_file.cc +++ b/src/exif/jpeg_file.cc @@ -161,7 +161,12 @@ PlatformResult JpegFile::load(const std::string& path) { } const std::size_t in_file_size = static_cast(ftell_val); - fseek(m_in_file, 0, SEEK_SET); + res = fseek(m_in_file, 0, SEEK_SET); + if (0 != res) { + return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Reading JPEG file failed", + ("fseek failed with error! [%d]", res)); + } + LoggerD("JPEG file: [%s] size:%d", path.c_str(), in_file_size); if (0 == in_file_size) { return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "JPEG file is invalid", -- 2.34.1