From: Pawel Andruszkiewicz
Date: Thu, 11 Jun 2015 09:06:45 +0000 (+0200)
Subject: [Archive] Replaced strerror() with safer implementation.
X-Git-Tag: submit/tizen/20150702.103311^2~2^2~55
X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fbe712b3ece3593acd686b5d6c14a5b0a1d9952b;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git
[Archive] Replaced strerror() with safer implementation.
Prevent CID: 439636, 443886, 445942, 447783, 447925
[Verification] TCT pass rate: 100%
Change-Id: Ic771266da5474ca71f9cdd88e5040c4f0122ecbc
Signed-off-by: Pawel Andruszkiewicz
---
diff --git a/src/archive/un_zip_extract_request.cc b/src/archive/un_zip_extract_request.cc
index fd96a319..aeebcd8e 100755
--- a/src/archive/un_zip_extract_request.cc
+++ b/src/archive/un_zip_extract_request.cc
@@ -26,6 +26,8 @@
#include
#include "common/logger.h"
+#include "common/tools.h"
+
#include "filesystem_file.h"
#include "archive_file.h"
#include "archive_utils.h"
@@ -35,6 +37,7 @@ namespace extension {
namespace archive {
using namespace common;
+using common::tools::GetErrorString;
FilePathStatus getPathStatus(const std::string& path)
{
@@ -94,8 +97,8 @@ void createMissingDirectories(const std::string& path, bool check_first = true)
if(FPS_DIRECTORY != status) {
//TODO investigate 0775 (mode) - filesystem assumed that file should have parent mode
if(mkdir(left_part.c_str(), 0775) == -1) {
- LoggerE("Couldn't create new directory: %s errno:%s",
- left_part.c_str(), strerror(errno));
+ LoggerE("Couldn't create new directory: %s errno: %s",
+ left_part.c_str(), GetErrorString(errno).c_str());
//TODO check why mkdir return -1 but directory is successfully created
// throw UnknownException(
// "Could not create new directory");
@@ -125,7 +128,7 @@ void changeFileAccessAndModifyDate(const std::string& filepath, tm_unz tmu_date)
ut.actime = ut.modtime = mktime(&newdate);
if(utime(filepath.c_str(), &ut) == -1) {
- LoggerE("Couldn't set time for: [%s] errno:%s", filepath.c_str(), strerror(errno));
+ LoggerE("Couldn't set time for: [%s] errno: %s", filepath.c_str(), GetErrorString(errno).c_str());
}
}
@@ -194,8 +197,8 @@ UnZipExtractRequest::~UnZipExtractRequest()
if(m_delete_output_file && !m_is_directory_entry) {
if(std::remove(m_output_filepath.c_str()) != 0) {
LoggerE("Couldn't remove partial file! "
- "std::remove(\"%s\") failed with errno:%s",
- m_output_filepath.c_str(), strerror(errno));
+ "std::remove(\"%s\") failed with errno: %s",
+ m_output_filepath.c_str(), GetErrorString(errno).c_str());
}
}
@@ -289,8 +292,8 @@ PlatformResult UnZipExtractRequest::handleDirectoryEntry()
if(m_callback->getOverwrite()) { //Is a file & overwrite is set:
std::string fn = removeTrailingDirectorySlashFromPath(m_new_dir_path);
if(std::remove(fn.c_str()) != 0) {
- LoggerE("std::remove(\"%s\") failed with errno:%s",
- m_new_dir_path.c_str(), strerror(errno));
+ LoggerE("std::remove(\"%s\") failed with errno: %s",
+ m_new_dir_path.c_str(), GetErrorString(errno).c_str());
return PlatformResult(ErrorCode::UNKNOWN_ERR, "Could not overwrite file in output directory");
}
} else { //Is a file & overwrite is not set:
@@ -303,8 +306,8 @@ PlatformResult UnZipExtractRequest::handleDirectoryEntry()
//Try to create new directory in output directory
if(mkdir(m_new_dir_path.c_str(), 0775) == -1) {
- LoggerE("Couldn't create new directory: %s errno:%s",
- m_new_dir_path.c_str(), strerror(errno));
+ LoggerE("Couldn't create new directory: %s errno: %s",
+ m_new_dir_path.c_str(), GetErrorString(errno).c_str());
return PlatformResult(ErrorCode::UNKNOWN_ERR, "Could not create new directory in extract output directory");
}
}
@@ -340,8 +343,8 @@ PlatformResult UnZipExtractRequest::prepareOutputSubdirectory()
//Try to create new directory in output directory
//TODO investigate 0775 (mode) - filesystem assumed that file should have parent mode
if(mkdir(m_new_dir_path.c_str(), 0775) == -1) {
- LoggerW("couldn't create new directory: %s errno:%s",
- m_new_dir_path.c_str(), strerror(errno));
+ LoggerW("couldn't create new directory: %s errno: %s",
+ m_new_dir_path.c_str(), GetErrorString(errno).c_str());
//TODO check why mkdir return -1 but directory is successfully created
// throw UnknownException(
// "Could not create new directory in extract output directory");