Fix static analysis issue 89/297089/3
authorilho kim <ilho159.kim@samsung.com>
Thu, 10 Aug 2023 05:30:20 +0000 (14:30 +0900)
committerilho kim <ilho159.kim@samsung.com>
Thu, 10 Aug 2023 05:37:51 +0000 (14:37 +0900)
Check the return value of glob()

Change-Id: I7f526ca453ccdde105d44193914833f0ec512868
Signed-off-by: ilho kim <ilho159.kim@samsung.com>
src/wgt/step/security/step_check_extension_privileges.cc

index 796022d..e40fc6b 100755 (executable)
@@ -56,11 +56,16 @@ common_installer::Step::Status StepCheckExtensionPrivileges::process() {
   std::set<std::string> xmlFiles;
   {
     glob_t glob_result;
-    glob(app_ext_config_pattern.c_str(), GLOB_TILDE, NULL, &glob_result);
-    for (unsigned int i = 0; i < glob_result.gl_pathc; ++i) {
-      xmlFiles.insert(glob_result.gl_pathv[i]);
+    int ret = glob(app_ext_config_pattern.c_str(),
+        GLOB_TILDE, NULL, &glob_result);
+    if (ret == 0) {
+      for (unsigned int i = 0; i < glob_result.gl_pathc; ++i) {
+        xmlFiles.insert(glob_result.gl_pathv[i]);
+      }
+      globfree(&glob_result);
+    } else {
+      LOG(ERROR) << "Fail to get extension paths, error code : " << ret;
     }
-    globfree(&glob_result);
   }
   GList* privileges = nullptr;
   BOOST_SCOPE_EXIT_ALL(privileges) {