Fix incorrect TPA error accepted/tizen/unified/20240329.131808 accepted/tizen/unified/x/20240401.142627
authorWoongsuk Cho <ws77.cho@samsung.com>
Thu, 28 Mar 2024 21:58:08 +0000 (06:58 +0900)
committer조웅석/MDE Lab(SR)/삼성전자 <ws77.cho@samsung.com>
Fri, 29 Mar 2024 03:40:36 +0000 (12:40 +0900)
The isManagedAssembly() function receives a file name as an input and checks only the extension.
But, it calls isR2RImage(), which requires a full path to the file internally.

Upon checking the usage of the isManageAssembly() function,
it is confirmed that it is used only to check whether it is a dll file or not.

So, the isManagedAssembly() function has been modified to return true even in the case of including a native image,
and related codes have been reorganized.

NativeLauncher/inc/utils.h
NativeLauncher/launcher/exec/corerun.cc
NativeLauncher/tool/ni_common.cc
NativeLauncher/util/utils.cc

index dca091f..38c6361 100644 (file)
@@ -159,10 +159,9 @@ bool isDirectory(const std::string& path);
 /**
  * @brief check the file is managed assembly or not.
  * @param[in] file path
- * @return return true when the file is managed assembly.
- *         otherwise return false including native image case.
- */
-bool isManagedAssembly(const std::string& filePath);
+ * @return return true when the file is managed assembly even if it includes a native image.
+  */
+bool isManagedAssembly(const std::string& fileName);
 
 /**
  * @brief Resolve assembly files from directories and append their paths to the given list.
index 820679b..887912b 100644 (file)
@@ -103,7 +103,7 @@ int main(int argc, const char* argv[]) {
                        _SERR("Unknown option %s.", argv[0]);
                        DisplayUsage();
                        return -1;
-               } else if (isManagedAssembly(arg) || isR2RImage(arg)) {
+               } else if (isManagedAssembly(arg)) {
                        if (!isFile(arg)) {
                                _SERR("The specified file does not exist.");
                                return -1;
index cf3a02b..36c2040 100644 (file)
@@ -299,7 +299,7 @@ static bool checkDllExistInDir(const std::string& path)
 {
        bool ret = false;
        auto func = [&ret](const std::string& f_path, const std::string& f_name) {
-               if (isManagedAssembly(f_name) || isR2RImage(f_name)) {
+               if (isManagedAssembly(f_name)) {
                        ret = true;
                }
        };
@@ -321,7 +321,7 @@ static ni_error_e getTargetDllList(const std::string& path, std::vector<std::str
        }
 
        auto func = [&fileList, opt](const std::string& f_path, const std::string& f_name) {
-               if (isManagedAssembly(f_path) && !checkNIExistence(f_path, opt)) {
+               if (isManagedAssembly(f_name) && !checkNIExistence(f_path, opt)) {
                        fileList.push_back(getAbsolutePath(f_path));
                }
        };
index c729395..f1dcc59 100644 (file)
@@ -56,7 +56,7 @@ static bool iCompare(const std::string& a, int aOffset, const std::string& b, in
 
 bool isManagedAssembly(const std::string& fileName)
 {
-       return iCompare(fileName, fileName.size()-4, ".dll", 0, 4) && !isR2RImage(fileName);
+       return iCompare(fileName, fileName.size()-4, ".dll", 0, 4);
 }
 
 std::string concatPath(const std::string& path1, const std::string& path2)
@@ -338,13 +338,13 @@ void addAssembliesFromDirectories(const std::vector<std::string>& directories, s
        std::unordered_map<std::string, std::string> assemPaths;
 
        auto reader = [&assems, &assemPaths](const std::string& path, const std::string& filename) {
-               if (isManagedAssembly(filename) || isR2RImage(filename)) {
+               if (isManagedAssembly(filename)) {
                        std::string assem = getAssemblyNameFromPath(filename);
 
                        if (assemPaths.count(assem) == 0) {
                                assems.push_back(assem);
                                assemPaths[assem] = path;
-                       } else if (isManagedAssembly(assemPaths[assem]) && isR2RImage(filename)) {
+                       } else if (isR2RImage(path)) {
                                // Update only if a native image is found in the same directory.
                                // For example, if we have two directories = { X, Y } where X contains A.dll and
                                // Y contains both A.dll and A.ni.dll, always A.dll in X will be used.