[Filesystem] Resolving unexpected result of coverity issues 28/179928/1
authorRafal Walczyna <r.walczyna@partner.samsung.com>
Wed, 23 May 2018 10:39:08 +0000 (12:39 +0200)
committerRafal Walczyna <r.walczyna@partner.samsung.com>
Wed, 23 May 2018 10:39:08 +0000 (12:39 +0200)
Time of checking to time of use is already short as possible.

[verification] Build successful

Change-Id: Ifa55b413962fb88321771ac952487f6901581790
Signed-off-by: Rafal Walczyna <r.walczyna@partner.samsung.com>
src/filesystem/filesystem_manager.cc
src/filesystem/filesystem_manager.h
src/filesystem/filesystem_stat.cc
src/filesystem/filesystem_stat.h

index a95f5b171efb2997794d1d736c9d3e41b77ad811..8ca885d36520b8365e50012d44ac927f0d8b6777 100644 (file)
@@ -289,8 +289,7 @@ void FilesystemManager::MakeDirectory(const std::string& path,
   result_cb(make_directory_worker(path));
 }
 
-// pass oldPath by copy to prevent possible TOCTOU bug
-void FilesystemManager::Rename(const std::string oldPath, const std::string& newPath,
+void FilesystemManager::Rename(const std::string& oldPath, const std::string& newPath,
                                const std::function<void(const FilesystemStat&)>& success_cb,
                                const std::function<void(FilesystemError)>& error_cb) {
   ScopeLogger();
index eaadf9ba0b1e359b399e923627bb01230c3cebfa..e0d2d12b8aa809e56db0dee5f7c4c67d87b70346 100644 (file)
@@ -69,7 +69,7 @@ class FilesystemManager {
                   const std::function<void(const FilesystemStat&)>& success_cb,
                   const std::function<void(FilesystemError)>& error_cb);
 
-  void Rename(const std::string oldPath, const std::string& newPath,
+  void Rename(const std::string& oldPath, const std::string& newPath,
               const std::function<void(const FilesystemStat&)>& success_cb,
               const std::function<void(FilesystemError)>& error_cb);
 
index bb5bc89be1c0a3e2d87dbf20c754ad800621892a..feb7bed6f18cbd016a8b61f67579973c5a600681 100644 (file)
@@ -59,8 +59,7 @@ picojson::value FilesystemStat::toJSON() const {
   return retval;
 }
 
-// pass path by copy to prevent possible TOCTOU bug
-FilesystemStat FilesystemStat::getStat(const std::string path) {
+FilesystemStat FilesystemStat::getStat(const std::string& path) {
   ScopeLogger();
   struct stat aStatObj;
   FilesystemStat _result;
index 31c58875ab1bbcf76648aaabde7e47c702f99ad3..a984ab1dbaa49cedd0452c6bef5c2572d8f5e44a 100755 (executable)
@@ -49,7 +49,7 @@ class FilesystemStat {
 
   picojson::value toJSON() const;
 
-  static FilesystemStat getStat(const std::string path);
+  static FilesystemStat getStat(const std::string& path);
 };
 }  // namespace filesystem
 }  // namespace extension