[filesystem] Fixing SVACE issues, type PROC_USE.VULNERABLE 14/180314/1
authorRafal Walczyna <r.walczyna@partner.samsung.com>
Mon, 28 May 2018 08:00:25 +0000 (10:00 +0200)
committerRafal Walczyna <r.walczyna@partner.samsung.com>
Mon, 28 May 2018 08:00:25 +0000 (10:00 +0200)
[verification] build successful

Change-Id: I93a7f187810993a7d0bfb6ed0a1ece0ff2b9ed53
Signed-off-by: Rafal Walczyna <r.walczyna@partner.samsung.com>
src/filesystem/filesystem_utils.cc

index f56cab79682a89da8aee2ac0e3658d92dcf67d9c..64fa20666465d6aaf96f81f7c5afdb4af8f05671 100644 (file)
@@ -31,6 +31,7 @@ namespace FilesystemUtils {
 using namespace std::string_literals;
 using namespace common;
 using common::tools::ReportError;
+using common::tools::GetErrorString;
 
 void Mkdir(const std::string& path) {
   ScopeLogger("%s", path.c_str());
@@ -192,7 +193,7 @@ void ListDirectory(const std::string& path, std::function<void(const char*, unsi
   DIR* d = ::opendir(path.c_str());
   if (nullptr == d) {
     throw std::system_error{errno, std::generic_category(),
-                            "Failed to open directory: "s + std::strerror(errno)};
+                            "Failed to open directory: "s + GetErrorString(errno)};
   }
 
   std::unique_ptr<DIR, void (*)(DIR*)> dir_ptr(d, [](DIR* d) {
@@ -211,7 +212,7 @@ void ListDirectory(const std::string& path, std::function<void(const char*, unsi
 
   if (0 != errno) {
     throw std::system_error{errno, std::generic_category(),
-                            "Failed to read directory: "s + std::strerror(errno)};
+                            "Failed to read directory: "s + GetErrorString(errno)};
   }
 }
 
@@ -226,7 +227,7 @@ void RemoveDirectoryRecursively(const std::string& path) {
 
              auto res = remove(fpath);
              if (res) {
-               LoggerD("Failed to remove %s: %s", fpath, std::strerror(errno));
+               LoggerD("Failed to remove %s: %s", fpath, GetErrorString(errno));
                return errno;
              }
              return 0;
@@ -240,7 +241,7 @@ void RemoveDirectoryRecursively(const std::string& path) {
       res = EIO;
     }
     throw std::system_error{res, std::generic_category(),
-                            "Failed to remove directory recursively: "s + std::strerror(res)};
+                            "Failed to remove directory recursively: "s + GetErrorString(res)};
   }
 }
 
@@ -269,7 +270,7 @@ bool CheckIfExists(const std::string& path, struct stat* buf) {
       return false;
     } else {
       throw std::system_error{errno, std::generic_category(),
-                              "Unable to check file existence: "s + std::strerror(errno)};
+                              "Unable to check file existence: "s + GetErrorString(errno)};
     }
   }
   return true;
@@ -295,7 +296,7 @@ void Rename(const std::string& path, const std::string& new_path) {
   ScopeLogger();
   if (::rename(path.c_str(), new_path.c_str())) {
     throw std::system_error{errno, std::generic_category(),
-                            "Unable to rename file or directory: "s + std::strerror(errno)};
+                            "Unable to rename file or directory: "s + GetErrorString(errno)};
   }
 }
 
@@ -338,7 +339,7 @@ void MoveDirectory(const std::string& src, const std::string& dest, bool overwri
     } else if (EXDEV != errno) {
       // The directories are in the same mount point, but the operation has just failed.
       throw std::system_error{EIO, std::generic_category(),
-                              "Unable to move directory: "s + std::strerror(errno)};
+                              "Unable to move directory: "s + GetErrorString(errno)};
     }
   }