summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorj-h.choi <j-h.choi@samsung.com>2019-11-19 14:51:41 +0900
committer조웅석/Common Platform Lab(SR)/Principal Engineer/삼성전자 <ws77.cho@samsung.com>2019-11-20 10:05:16 +0900
commitdf8ae3f254ae060fbebfe1d6adf94f22398790fe (patch)
tree849a0b8c036c2b0836f87a5e091a2b90596209f9
parent42f6440f9ef4fe3441fea4f8426c2be02eaa398c (diff)
downloadlauncher-df8ae3f254ae060fbebfe1d6adf94f22398790fe.tar.gz
launcher-df8ae3f254ae060fbebfe1d6adf94f22398790fe.tar.bz2
launcher-df8ae3f254ae060fbebfe1d6adf94f22398790fe.zip
Fixed Svace issue
-rw-r--r--NativeLauncher/installer-plugin/prefer_dotnet_aot_plugin.cc7
-rw-r--r--NativeLauncher/installer-plugin/prefer_nuget_cache_plugin.cc265
-rw-r--r--NativeLauncher/tool/ni_common.cc2
-rw-r--r--NativeLauncher/tool/tac_common.cc5
-rw-r--r--NativeLauncher/tool/tpatool.cc11
5 files changed, 161 insertions, 129 deletions
diff --git a/NativeLauncher/installer-plugin/prefer_dotnet_aot_plugin.cc b/NativeLauncher/installer-plugin/prefer_dotnet_aot_plugin.cc
index 893bce1..161d8d6 100644
--- a/NativeLauncher/installer-plugin/prefer_dotnet_aot_plugin.cc
+++ b/NativeLauncher/installer-plugin/prefer_dotnet_aot_plugin.cc
@@ -80,8 +80,9 @@ extern "C" int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgId, const char *app
std::string binDir = concatPath(pkgRoot, "bin");
std::string tacDir = concatPath(binDir, TAC_SYMLINK_SUB_DIR);
if (bf::exists(tacDir)) {
- uid_t uid = 0;
- if (pkgmgr_installer_info_get_target_uid(&uid) < 0) {
+ uid_t g_uid = 0;
+ gid_t g_gid = 0;
+ if (pkgmgr_installer_info_get_target_uid(&g_uid) < 0) {
_ERR("Failed to get UID");
return 0;
}
@@ -101,7 +102,7 @@ extern "C" int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgId, const char *app
if (!bf::exists(setNiPath)) {
bf::create_symlink(originNiPath, setNiPath);
_INFO("%s symbolic link file generated successfully.", setNiPath.c_str());
- if (lchown(setNiPath.c_str(), uid, 0)) {
+ if (lchown(setNiPath.c_str(), g_uid, g_gid)) {
_ERR("Failed to change owner of: %s", setNiPath.c_str());
return -1;
}
diff --git a/NativeLauncher/installer-plugin/prefer_nuget_cache_plugin.cc b/NativeLauncher/installer-plugin/prefer_nuget_cache_plugin.cc
index f204e72..7f75b37 100644
--- a/NativeLauncher/installer-plugin/prefer_nuget_cache_plugin.cc
+++ b/NativeLauncher/installer-plugin/prefer_nuget_cache_plugin.cc
@@ -149,10 +149,62 @@ void SHA256(std::string path, char outputBuffer[65])
free(buffer);
}
+void createSHA256Info(std::string sha256_info, std::string np)
+{
+ std::ofstream ofs(sha256_info, std::ios::app);
+ int assembly_count = 0;
+ for (auto& npAssemblySha : nugetPackagesAssembliesSha) {
+ std::string nuget_package_assembly = npAssemblySha.substr(0, npAssemblySha.rfind(':'));
+ std::string nuget_package = nuget_package_assembly.substr(0, nuget_package_assembly.rfind(':'));
+ std::string assembly = nuget_package_assembly.substr(nuget_package_assembly.rfind(':') + 1);
+ std::string sha = npAssemblySha.substr(npAssemblySha.rfind(':') + 1);
+ if (!strcmp(nuget_package.c_str(), np.c_str())) {
+ ofs << assembly << ":" << sha << std::endl;
+ assembly_count++;
+ }
+ }
+ ofs << assembly_count << std::endl;
+ ofs.close();
+}
+
+int compareSHA256Info(std::string sha256_info, std::string np)
+{
+ int compare_count = 0;
+ int assembly_count = 0;
+ std::string sha256_count = "0";
+ for (auto& npAssemblySha : nugetPackagesAssembliesSha) {
+ std::string nuget_package_assembly = npAssemblySha.substr(0, npAssemblySha.rfind(':'));
+ std::string nuget_package = nuget_package_assembly.substr(0, nuget_package_assembly.rfind(':'));
+ std::string assembly = nuget_package_assembly.substr(nuget_package_assembly.rfind(':') + 1);
+ std::string sha = npAssemblySha.substr(npAssemblySha.rfind(':') + 1);
+ if (!strcmp(nuget_package.c_str(), np.c_str())) {
+ assembly_count++;
+ std::ifstream ifs(sha256_info);
+ std::string get_str;
+ if (ifs.is_open()) {
+ while (getline(ifs, get_str)) {
+ if (!strcmp(get_str.c_str(), (assembly + ":" + sha).c_str())) {
+ compare_count++;
+ }
+ sha256_count = get_str;
+ }
+ ifs.close();
+ }
+ }
+ }
+ if (!strcmp(std::to_string(assembly_count).c_str(), std::to_string(compare_count).c_str()) &&
+ !strcmp(std::to_string(assembly_count).c_str(), sha256_count.c_str())) {
+ _INFO("Same nuget : %s", np.c_str());
+ return 1;
+ }
+ return 0;
+}
+
int copyNCreateSymlink(std::string tac_version_dir, std::string np, bool is_create_tac_dir)
{
- uid_t uid = 0;
- if (pkgmgr_installer_info_get_target_uid(&uid) < 0) {
+ uid_t g_uid = 0;
+ gid_t g_gid = 0;
+ if (pkgmgr_installer_info_get_target_uid(&g_uid) < 0) {
_ERR("Failed to get UID");
return -1;
}
@@ -176,7 +228,7 @@ int copyNCreateSymlink(std::string tac_version_dir, std::string np, bool is_crea
}
}
bf::create_symlink(concatPath(tac_version_dir, assembly), concatPath(tac_dir, assembly));
- if (lchown(concatPath(tac_dir, assembly).c_str(), uid, 0)) {
+ if (lchown(concatPath(tac_dir, assembly).c_str(), g_uid, g_gid)) {
_ERR("Failed to change owner of: %s", concatPath(tac_dir, assembly).c_str());
return -1;
}
@@ -252,65 +304,43 @@ extern "C" int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgId, const char *app
return 0;
}
createDirectories.push_back(tac_version_dir);
- std::ofstream ofs(sha256_info, std::ios::app);
- int assembly_count = 0;
- for (auto& npAssemblySha : nugetPackagesAssembliesSha) {
- std::string nuget_package_assembly = npAssemblySha.substr(0, npAssemblySha.rfind(':'));
- std::string nuget_package = nuget_package_assembly.substr(0, nuget_package_assembly.rfind(':'));
- std::string assembly = nuget_package_assembly.substr(nuget_package_assembly.rfind(':') + 1);
- std::string sha = npAssemblySha.substr(npAssemblySha.rfind(':') + 1);
- if (!strcmp(nuget_package.c_str(), np.c_str())) {
- ofs << assembly << ":" << sha << std::endl;
- assembly_count++;
- }
+ if (!bf::is_symlink(sha256_info)) {
+ createSHA256Info(sha256_info, np);
+ } else {
+ _ERR("Failed to create sha256_info. Symbolic link is detected");
+ return -1;
}
- ofs << assembly_count << std::endl;
- ofs.close();
if (copyNCreateSymlink(tac_version_dir, np, true) < 0) {
_ERR("Failed to create symlink");
return -1;
}
- std::string sql = "INSERT INTO TAC (PKGID, NUGET, NAME, VERSION) " \
- "VALUES ('" + std::string(pkgId) + "', '" + np + "', '" + tac_name + "', '" + tac_version + "');";
+
+ char *sql = sqlite3_mprintf(
+ "INSERT INTO TAC (PKGID, NUGET, NAME, VERSION) " \
+ "VALUES (%Q, %Q, %Q, %Q);", pkgId, np.c_str(), tac_name.c_str(), tac_version.c_str());
dbInsert(tac_db, TAC_APP_LIST_DB, sql);
+ sqlite3_free(sql);
} else {
_INFO("Exists tac_version_dir [%s]", tac_version_dir.c_str());
- int compare_count = 0;
- int assembly_count = 0;
- std::string sha256_count = "0";
- for (auto& npAssemblySha : nugetPackagesAssembliesSha) {
- std::string nuget_package_assembly = npAssemblySha.substr(0, npAssemblySha.rfind(':'));
- std::string nuget_package = nuget_package_assembly.substr(0, nuget_package_assembly.rfind(':'));
- std::string assembly = nuget_package_assembly.substr(nuget_package_assembly.rfind(':') + 1);
- std::string sha = npAssemblySha.substr(npAssemblySha.rfind(':') + 1);
- if (!strcmp(nuget_package.c_str(), np.c_str())) {
- assembly_count++;
- std::ifstream ifs(sha256_info);
- std::string get_str;
- if (ifs.is_open()) {
- while (getline(ifs, get_str)) {
- if (!strcmp(get_str.c_str(), (assembly + ":" + sha).c_str())) {
- compare_count++;
- }
- sha256_count = get_str;
- }
- ifs.close();
+ if (!bf::is_symlink(sha256_info)) {
+ if (compareSHA256Info(sha256_info, np)) {
+ if (copyNCreateSymlink(tac_version_dir, np, false) < 0) {
+ _ERR("Failed to create symlink");
+ return -1;
}
+
+ char *sql = sqlite3_mprintf(
+ "INSERT INTO TAC (PKGID, NUGET, NAME, VERSION) " \
+ "VALUES (%Q, %Q, %Q, %Q);", pkgId, np.c_str(), tac_name.c_str(), tac_version.c_str());
+ dbInsert(tac_db, TAC_APP_LIST_DB, sql);
+ sqlite3_free(sql);
+ } else {
+ _INFO("Different nuget : %s", np.c_str());
}
- }
- if (!strcmp(std::to_string(assembly_count).c_str(), std::to_string(compare_count).c_str()) &&
- !strcmp(std::to_string(assembly_count).c_str(), sha256_count.c_str())) {
- _INFO("Same nuget : %s", np.c_str());
- if (copyNCreateSymlink(tac_version_dir, np, false) < 0) {
- _ERR("Failed to create symlink");
- return -1;
- }
- std::string sql = "INSERT INTO TAC (PKGID, NUGET, NAME, VERSION) " \
- "VALUES ('" + std::string(pkgId) + "', '" + np + "', '" + tac_name + "', '" + tac_version + "');";
- dbInsert(tac_db, TAC_APP_LIST_DB, sql);
} else {
- _INFO("Different nuget : %s", np.c_str());
+ _ERR("Failed to create sha256_info. Symbolic link is detected");
+ return -1;
}
}
if (!bf::exists(sha256_info)) {
@@ -332,10 +362,11 @@ int updateTacDB(sqlite3 *sqlite)
{
for (auto& unp : updateTac) {
int count = -1;
- std::string sql = "SELECT COUNT(NUGET) FROM TAC WHERE NUGET = '" + unp + "';";
- int ret = sqlite3_exec(sqlite, sql.c_str(), sqliteCb, &count, NULL);
+ char *sql = sqlite3_mprintf("SELECT COUNT(NUGET) FROM TAC WHERE NUGET = %Q;", unp.c_str());
+ int ret = sqlite3_exec(sqlite, sql, sqliteCb, &count, NULL);
if (ret != SQLITE_OK) {
_ERR("Sqlite select error");
+ sqlite3_free(sql);
return -1;
}
if (count == 0) {
@@ -343,13 +374,16 @@ int updateTacDB(sqlite3 *sqlite)
std::string tac_version_dir_backup = tac_version_dir_prev + ".bck";
if (!copyDir(tac_version_dir_prev, tac_version_dir_backup)) {
_ERR("Failed to copy of %s to %s", tac_version_dir_prev.c_str(), tac_version_dir_backup.c_str());
+ sqlite3_free(sql);
return -1;
}
if (!removeAll(tac_version_dir_prev)) {
_ERR("Failed to remove of %s", tac_version_dir_prev.c_str());
+ sqlite3_free(sql);
return -1;
}
}
+ sqlite3_free(sql);
}
return 0;
}
@@ -386,12 +420,14 @@ extern "C" int PKGMGR_MDPARSER_PLUGIN_UPGRADE(const char *pkgId, const char *app
return 0;
}
- std::string sql = "SELECT * FROM TAC WHERE PKGID = '" + std::string(pkgId) + "';";
+ char *sql = sqlite3_mprintf("SELECT * FROM TAC WHERE PKGID = %Q;", pkgId);
updateTac = dbSelect(tac_db, TAC_APP_LIST_DB, sql);
+ sqlite3_free(sql);
if (tacDB.empty()) {
- sql = "DELETE FROM TAC WHERE PKGID = '" + std::string(pkgId) + "';";
+ sql = sqlite3_mprintf("DELETE FROM TAC WHERE PKGID = %Q;", pkgId);
dbDelete(tac_db, TAC_APP_LIST_DB, sql);
+ sqlite3_free(sql);
if (updateTacDB(tac_db) < 0) {
return -1;
}
@@ -411,91 +447,77 @@ extern "C" int PKGMGR_MDPARSER_PLUGIN_UPGRADE(const char *pkgId, const char *app
return 0;
}
createDirectories.push_back(tac_version_dir);
- std::ofstream ofs(sha256_info, std::ios::app);
- int assembly_count = 0;
- for (auto& npAssemblySha : nugetPackagesAssembliesSha) {
- std::string nuget_package_assembly = npAssemblySha.substr(0, npAssemblySha.rfind(':'));
- std::string nuget_package = nuget_package_assembly.substr(0, nuget_package_assembly.rfind(':'));
- std::string assembly = nuget_package_assembly.substr(nuget_package_assembly.rfind(':') + 1);
- std::string sha = npAssemblySha.substr(npAssemblySha.rfind(':') + 1);
- if (!strcmp(nuget_package.c_str(), np.c_str())) {
- ofs << assembly << ":" << sha << std::endl;
- assembly_count++;
- }
+ if (!bf::is_symlink(sha256_info)) {
+ createSHA256Info(sha256_info, np);
+ } else {
+ _ERR("Failed to create sha256_info. Symbolic link is detected");
+ return -1;
}
- ofs << assembly_count << std::endl;
- ofs.close();
+
if (copyNCreateSymlink(tac_version_dir, np, true) < 0) {
_ERR("Failed to create symlink");
return -1;
}
int count = -1;
- sql = "SELECT COUNT(NUGET) FROM TAC WHERE PKGID = '" + std::string(pkgId) + "' AND NAME = '" + tac_name + "';";
- int ret = sqlite3_exec(tac_db, sql.c_str(), sqliteCb, &count, NULL);
+ sql = sqlite3_mprintf(
+ "SELECT COUNT(NUGET) FROM TAC WHERE PKGID = %Q AND NAME = %Q;", pkgId, tac_name.c_str());
+ int ret = sqlite3_exec(tac_db, sql, sqliteCb, &count, NULL);
if (ret != SQLITE_OK) {
_ERR("Sqlite select error");
+ sqlite3_free(sql);
return -1;
}
if (count == 1) {
- sql = "UPDATE TAC SET NAME = '" + tac_name + "', VERSION = '" + tac_version + "', NUGET = '" + np + "' WHERE PKGID = '" + std::string(pkgId) + "' AND NAME = '" + tac_name + "';";
+ sql = sqlite3_mprintf(
+ "UPDATE TAC SET NAME = %Q, VERSION = %Q, NUGET = %Q WHERE PKGID = %Q AND NAME = %Q;",
+ tac_name.c_str(), tac_version.c_str(), np.c_str(), pkgId, tac_name.c_str());
dbUpdate(tac_db, TAC_APP_LIST_DB, sql);
+ sqlite3_free(sql);
} else if (count == 0) {
- sql = "INSERT INTO TAC (PKGID, NUGET, NAME, VERSION) " \
- "VALUES ('" + std::string(pkgId) + "', '" + np + "', '" + tac_name + "', '" + tac_version + "');";
+ sql = sqlite3_mprintf(
+ "INSERT INTO TAC (PKGID, NUGET, NAME, VERSION) " \
+ "VALUES (%Q, %Q, %Q, %Q);", pkgId, np.c_str(), tac_name.c_str(), tac_version.c_str());
dbInsert(tac_db, TAC_APP_LIST_DB, sql);
+ sqlite3_free(sql);
}
} else {
_INFO("Exists tac_version_dir [%s]", tac_version_dir.c_str());
- int compare_count = 0;
- int assembly_count = 0;
- std::string sha256_count = "0";
- for (auto& npAssemblySha : nugetPackagesAssembliesSha) {
- std::string nuget_package_assembly = npAssemblySha.substr(0, npAssemblySha.rfind(':'));
- std::string nuget_package = nuget_package_assembly.substr(0, nuget_package_assembly.rfind(':'));
- std::string assembly = nuget_package_assembly.substr(nuget_package_assembly.rfind(':') + 1);
- std::string sha = npAssemblySha.substr(npAssemblySha.rfind(':') + 1);
- if (!strcmp(nuget_package.c_str(), np.c_str())) {
- assembly_count++;
- std::ifstream ifs(sha256_info);
- std::string get_str;
- if (ifs.is_open()) {
- while (getline(ifs, get_str)) {
- if (!strcmp(get_str.c_str(), (assembly + ":" + sha).c_str())) {
- compare_count++;
- }
- sha256_count = get_str;
- }
- ifs.close();
+ if (!bf::is_symlink(sha256_info)) {
+ if (compareSHA256Info(sha256_info, np)) {
+ if (copyNCreateSymlink(tac_version_dir, np, false) < 0) {
+ _ERR("Failed to create symlink");
+ return -1;
}
- }
- }
- if (!strcmp(std::to_string(assembly_count).c_str(), std::to_string(compare_count).c_str()) &&
- !strcmp(std::to_string(assembly_count).c_str(), sha256_count.c_str())) {
- _INFO("Same nuget : %s", np.c_str());
- if (copyNCreateSymlink(tac_version_dir, np, false) < 0) {
- _ERR("Failed to create symlink");
- return -1;
- }
-
- int count = -1;
- std::string sql = "SELECT COUNT(NUGET) FROM TAC WHERE PKGID = '" + std::string(pkgId) + "' AND NAME = '" + tac_name + "';";
- int ret = sqlite3_exec(tac_db, sql.c_str(), sqliteCb, &count, NULL);
- if (ret != SQLITE_OK) {
- _ERR("Sqlite select error");
- return -1;
- }
- if (count == 1) {
- sql = "UPDATE TAC SET NAME = '" + tac_name + "', VERSION = '" + tac_version + "', NUGET = '" + np + "' WHERE PKGID = '" + std::string(pkgId) + "' AND NAME = '" + tac_name + "';";
- dbUpdate(tac_db, TAC_APP_LIST_DB, sql);
- } else if (count == 0) {
- sql = "INSERT INTO TAC (PKGID, NUGET, NAME, VERSION) " \
- "VALUES ('" + std::string(pkgId) + "', '" + np + "', '" + tac_name + "', '" + tac_version + "');";
- dbInsert(tac_db, TAC_APP_LIST_DB, sql);
+ int count = -1;
+ char *sql = sqlite3_mprintf(
+ "SELECT COUNT(NUGET) FROM TAC WHERE PKGID = %Q AND NAME = %Q;", pkgId, tac_name.c_str());
+ int ret = sqlite3_exec(tac_db, sql, sqliteCb, &count, NULL);
+ if (ret != SQLITE_OK) {
+ _ERR("Sqlite select error");
+ sqlite3_free(sql);
+ return -1;
+ }
+ if (count == 1) {
+ sql = sqlite3_mprintf(
+ "UPDATE TAC SET NAME = %Q, VERSION = %Q, NUGET = %Q WHERE PKGID = %Q AND NAME = %Q;",
+ tac_name.c_str(), tac_version.c_str(), np.c_str(), pkgId, tac_name.c_str());
+ dbUpdate(tac_db, TAC_APP_LIST_DB, sql);
+ sqlite3_free(sql);
+ } else if (count == 0) {
+ sql = sqlite3_mprintf(
+ "INSERT INTO TAC (PKGID, NUGET, NAME, VERSION) " \
+ "VALUES (%Q, %Q, %Q, %Q);", pkgId, np.c_str(), tac_name.c_str(), tac_version.c_str());
+ dbInsert(tac_db, TAC_APP_LIST_DB, sql);
+ sqlite3_free(sql);
+ }
+ } else {
+ _INFO("Different nuget : %s", np.c_str());
}
} else {
- _INFO("Different nuget : %s", np.c_str());
+ _ERR("Failed to create sha256_info. Symbolic link is detected");
+ return -1;
}
}
if (!bf::exists(sha256_info)) {
@@ -513,8 +535,9 @@ extern "C" int PKGMGR_MDPARSER_PLUGIN_UPGRADE(const char *pkgId, const char *app
}
}
if (!isExits) {
- std::string sql = "DELETE FROM TAC WHERE PKGID = '" + std::string(pkgId) + "' AND NUGET = '" + unp + "';";
+ char *sql = sqlite3_mprintf("DELETE FROM TAC WHERE PKGID = %Q AND NUGET = %Q;", pkgId, unp.c_str());
dbDelete(tac_db, TAC_APP_LIST_DB, sql);
+ sqlite3_free(sql);
}
}
if (updateTacDB(tac_db) < 0) {
@@ -536,11 +559,13 @@ extern "C" int PKGMGR_MDPARSER_PLUGIN_UNINSTALL(const char *pkgId, const char *a
return 0;
}
- std::string sql = "SELECT * FROM TAC WHERE PKGID = '" + std::string(pkgId) + "';";
+ char *sql = sqlite3_mprintf("SELECT * FROM TAC WHERE PKGID = %Q;", pkgId);
updateTac = dbSelect(tac_db, TAC_APP_LIST_DB, sql);
+ sqlite3_free(sql);
- sql = "DELETE FROM TAC WHERE PKGID = '" + std::string(pkgId) + "';";
+ sql = sqlite3_mprintf("DELETE FROM TAC WHERE PKGID = %Q;", pkgId);
dbDelete(tac_db, TAC_APP_LIST_DB, sql);
+ sqlite3_free(sql);
if (updateTacDB(tac_db) < 0) {
return -1;
diff --git a/NativeLauncher/tool/ni_common.cc b/NativeLauncher/tool/ni_common.cc
index 6df388c..e4d04a5 100644
--- a/NativeLauncher/tool/ni_common.cc
+++ b/NativeLauncher/tool/ni_common.cc
@@ -763,7 +763,7 @@ static int regenTacCb(pkgmgrinfo_appinfo_h handle, void *userData)
return -1;
}
- std::string sql = "SELECT * FROM TAC WHERE PKGID = '" + std::string(pkgId) + "';";
+ char *sql = sqlite3_mprintf("SELECT * FROM TAC WHERE PKGID = %Q;", pkgId);
std::vector<std::string> nugets = dbSelect(tac_db, TAC_APP_LIST_DB, sql);
if (tac_db) {
diff --git a/NativeLauncher/tool/tac_common.cc b/NativeLauncher/tool/tac_common.cc
index 0cce217..ce104b8 100644
--- a/NativeLauncher/tool/tac_common.cc
+++ b/NativeLauncher/tool/tac_common.cc
@@ -121,8 +121,9 @@ static int restoreDBCb(pkgmgrinfo_appinfo_h handle, void *userData)
if (tac_db) {
std::string name = nuget.substr(0, nuget.find('/'));
std::string version = nuget.substr(nuget.rfind('/') + 1);
- std::string sql = "INSERT INTO TAC (PKGID, NUGET, NAME, VERSION) " \
- "VALUES ('" + std::string(pkgId) + "', '" + nuget + "', '" + name + "', '" + version + "');";
+ char *sql = sqlite3_mprintf(
+ "INSERT INTO TAC (PKGID, NUGET, NAME, VERSION) " \
+ "VALUES (%Q, %Q, %Q, %Q);", pkgId, nuget.c_str(), name.c_str(), version.c_str());
dbInsert(tac_db, TAC_APP_LIST_RESTORE_DB, sql);
restore_nuget.push_back(concatPath(__TAC_DIR, nuget));
}
diff --git a/NativeLauncher/tool/tpatool.cc b/NativeLauncher/tool/tpatool.cc
index e450207..8fff878 100644
--- a/NativeLauncher/tool/tpatool.cc
+++ b/NativeLauncher/tool/tpatool.cc
@@ -29,9 +29,14 @@ int main(int argc, char* argv[])
}
std::string tpaList = getTPA();
- std::ofstream out(PLATFORM_TPA_CACHE);
- out << tpaList;
- out.close();
+ if (!bf::is_symlink(PLATFORM_TPA_CACHE)) {
+ std::ofstream out(PLATFORM_TPA_CACHE);
+ out << tpaList;
+ out.close();
+ } else {
+ fprintf(stderr, "Failed to create platform_tpa_cache. Symbolic link is detected");
+ return -1;
+ }
return 0;
}