diff options
author | Woongsuk Cho <ws77.cho@samsung.com> | 2018-10-02 13:31:37 +0900 |
---|---|---|
committer | 조웅석/Tizen Platform Lab(SR)/Staff Engineer/삼성전자 <ws77.cho@samsung.com> | 2018-10-05 07:32:15 +0900 |
commit | 4b5e1f5102321d72859c2648aea630d32174680b (patch) | |
tree | bc0131d76c3cfebc4120579483bfc22b361ddbc4 | |
parent | e894220826ea81c7d3911912de45ba6e53ba48e4 (diff) | |
download | launcher-accepted/tizen/unified/20181010.061627.tar.gz launcher-accepted/tizen/unified/20181010.061627.tar.bz2 launcher-accepted/tizen/unified/20181010.061627.zip |
check size before calling substr()submit/tizen/20181005.002000accepted/tizen/unified/20181010.061627
-rw-r--r-- | NativeLauncher/installer-plugin/ni_common.cc | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/NativeLauncher/installer-plugin/ni_common.cc b/NativeLauncher/installer-plugin/ni_common.cc index f9e81b8..4c5ca44 100644 --- a/NativeLauncher/installer-plugin/ni_common.cc +++ b/NativeLauncher/installer-plugin/ni_common.cc @@ -71,20 +71,19 @@ static void waitInterval() static bool niExist(const std::string& path, std::string& ni) { - static std::string possibleExts[] = { - ".ni.dll", ".NI.dll", ".NI.DLL", ".ni.DLL", - ".ni.exe", ".NI.exe", ".NI.EXE", ".ni.EXE" - }; - std::string fName = path.substr(0, path.size() - 4); - - struct stat sb; - - for (std::string ext : possibleExts) { - std::string f = fName + ext; - if (stat(f.c_str(), &sb) == 0) { - ni = f; - return true; - } + size_t index = path.find_last_of("."); + if (index == std::string::npos) { + return false; + } + std::string fName = path.substr(0, index); + std::string fExt = path.substr(index, path.length()); + + // crossgen generate file with lower case extension only + std::transform(fExt.begin(), fExt.end(), fExt.begin(), ::tolower); + std::string f = fName + ".ni" + fExt; + if (isFileExist(f)) { + ni = f; + return true; } // native image of System.Private.CoreLib.dll should have to overwrite |