diff --git a/appspawn.cfg b/appspawn.cfg index dc40635ff69ce5afc0df373658b9977d84d9b52b..886e49d5020d44bee1baeceeaa90c3efcb7156c8 100755 --- a/appspawn.cfg +++ b/appspawn.cfg @@ -8,7 +8,8 @@ ], "services" : [{ "name" : "appspawn", - "path" : ["/system/bin/appspawn"], + "path" : ["/system/bin/appspawn", + "--process-name com.ohos.appspawn.startup --start-mode daemon --type standard"], "importance" : -20, "uid" : "root", "gid" : ["root"] diff --git a/src/appspawn_server.cpp b/src/appspawn_server.cpp index 2c8e7d11f11c52e8c570172a8506e97793b2658f..28ca476054e58f5167346a470cbb9cf34b7ee67e 100644 --- a/src/appspawn_server.cpp +++ b/src/appspawn_server.cpp @@ -268,7 +268,7 @@ int32_t AppSpawnServer::SetProcessName( } // set long process name - if (strncpy_s(longProcName, len, processName, len) != EOK) { + if (strncpy_s(longProcName, longProcNameLen, processName, len) != EOK) { HiLog::Error(LABEL, "strncpy_s long name error: %{public}d", strerror_r(errno, err_string, ERR_STRING_SZ)); return -EINVAL; } @@ -489,6 +489,17 @@ int32_t AppSpawnServer::SetKeepCapabilities(uint32_t uid) return ERR_OK; } +static int CheckProcessName(const std::string &processName) +{ + if (processName.empty() || processName.size() > ClientSocket::LEN_PROC_NAME) { + return -1; + } + if (processName.find('\\') != std::string::npos || processName.find('/') != std::string::npos) { + return -1; + } + return 0; +} + bool AppSpawnServer::CheckAppProperty(const ClientSocket::AppProperty *appProperty) { if (appProperty == nullptr) { @@ -501,8 +512,8 @@ bool AppSpawnServer::CheckAppProperty(const ClientSocket::AppProperty *appProper return false; } - if (strlen(appProperty->processName) == 0) { - HiLog::Error(LABEL, "process name length is 0"); + if (CheckProcessName(appProperty->processName) != 0) { + HiLog::Error(LABEL, "process name error"); return false; }