Fix for svace issue
authorWoongsuk Cho <ws77.cho@samsung.com>
Mon, 28 Jun 2021 01:03:43 +0000 (10:03 +0900)
committer조웅석/Common Platform Lab(SR)/Principal Engineer/삼성전자 <ws77.cho@samsung.com>
Mon, 28 Jun 2021 21:18:00 +0000 (06:18 +0900)
- change strcpy/strcat to strncpy/strncat
- use remove function insteadof system() call

NativeLauncher/launcher/lib/core_runtime.cc
NativeLauncher/tool/dotnettool.cc

index 9479ac7..b500b01 100644 (file)
@@ -539,8 +539,8 @@ int CoreRuntime::launch(const char* appId, const char* root, const char* path, i
                // set profile.data path and collect/use it if it non-exists/exists.
                if (profile) {
                        char multiCoreJitProfile[strlen(localDataPath) + strlen(PROFILE_BASENAME)];
-                       strcpy(multiCoreJitProfile, localDataPath);
-                       strcat(multiCoreJitProfile, PROFILE_BASENAME);
+                       strncpy(multiCoreJitProfile, localDataPath, strlen(localDataPath));
+                       strncat(multiCoreJitProfile, PROFILE_BASENAME, strlen(PROFILE_BASENAME));
 
                        setEnvironmentVariable("COMPlus_MultiCoreJitProfile", multiCoreJitProfile);
                        setEnvironmentVariable("COMPlus_MultiCoreJitMinNumCpus", "1");
index ffb52ca..38db4cd 100644 (file)
@@ -288,23 +288,29 @@ int main(int argc, char* argv[])
        //sh-3.2# dotnettool --rm-app-profile [pkgId] [pkgId] ...
        else if (cmd == "--rm-app-profile") {
                if (args.size() < 1) {
-                       fprintf(stderr, "Package name is missing\n");
+                       _SERR("Package name is missing");
                }
-               while (it != args.end()) {
-                       std::string pkg = std::string(*it);
-                       setenv("AUL_APPID", pkg.c_str(), 1);
-                       char *localDataPath = app_get_data_path(); // /root/apps_rw/<app_id>/data/
-                       if (localDataPath != NULL) {
-                               char *home = getenv("HOME"); // /root
-                               std::string rmCMD = std::string("rm -f /home/*");
-                               rmCMD.append(localDataPath + strlen(home)); // rm /home/*/apps_rw/<app_id>/data/
-                               rmCMD.append(PROFILE_BASENAME); // rm /home/*/apps_rw/<app_id>/data/.__tizen_specific_profile_data
-                               system(rmCMD.c_str());
-                               free(localDataPath);
-                       } else {
-                               fprintf(stderr, "Application not found [%s], skip to remove profile\n", pkg.c_str());
+               char *home = getenv("HOME"); // /root
+               if (home == NULL) {
+                       _SERR("Fail to get Home path from env");
+               } else {
+                       while (it != args.end()) {
+                               std::string pkg = std::string(*it);
+                               setenv("AUL_APPID", pkg.c_str(), 1);
+                               char *localDataPath = app_get_data_path(); // /root/apps_rw/<app_id>/data/
+                               if (localDataPath != NULL) {
+                                       std::string pDataFile = "/home/*";
+                                       pDataFile.append(localDataPath + strlen(home)); // /home/*/apps_rw/<app_id>/data/
+                                       pDataFile.append(PROFILE_BASENAME); // /home/*/apps_rw/<app_id>/data/.__tizen_specific_profile_data
+                                       if (!removeFile(pDataFile)) {
+                                               _SERR("Fail to remove file (%s)", pDataFile.c_str());
+                                       }
+                                       free(localDataPath);
+                               } else {
+                                       _SERR("Application not found [%s], skip to remove profile", pkg.c_str());
+                               }
+                               it = args.erase(it);
                        }
-                       it = args.erase(it);
                }
        }
        else {