!5230 增加选项参数长度限制

Merge pull request !5230 from 于文泽/debuggable
This commit is contained in:
openharmony_ci 2023-04-13 13:34:56 +00:00 committed by Gitee
commit 28ea2c57ec
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 16 additions and 17 deletions

View File

@ -1541,7 +1541,6 @@ int32_t AppMgrServiceInner::StartPerfProcess(const std::shared_ptr<AppRunningRec
AppSpawnStartMsg startMsg = appRecord->GetStartMsg();
if (!perfCmd.empty()) {
startMsg.renderParam = perfCmd;
HILOG_INFO("debuggablePipe perfCmd:%{public}s", perfCmd.c_str());
} else {
HILOG_INFO("debuggablePipe debugCmd:%{public}s", debugCmd.c_str());
@ -1549,14 +1548,6 @@ int32_t AppMgrServiceInner::StartPerfProcess(const std::shared_ptr<AppRunningRec
if (isSanboxApp) {
HILOG_INFO("debuggablePipe sandbox: true");
}
pid_t pid = 0;
ErrCode errCode = remoteClientManager_->GetSpawnClient()->StartProcess(startMsg, pid);
if (FAILED(errCode)) {
HILOG_ERROR("failed to spawn perf process, errCode %{public}08x", errCode);
appRunningManager_->RemoveAppRunningRecordById(appRecord->GetRecordId());
return errCode;
}
HILOG_INFO("Start perf process success, pid is %{public}d", pid);
return ERR_OK;
}

View File

@ -88,7 +88,10 @@ const std::string HELP_MSG_DUMPSYS = "usage: aa dump <options>\n"
const std::string HELP_MSG_PROCESS = "usage: aa process <options>\n"
"options list:\n"
" -h, --help list available commands\n"
" -a <ability-name> -b <bundle-name> [-m <module-name>] [-p <perf-cmd>] [-d <debug-cmd>] [-S] "
" -a <ability-name> -b <bundle-name> [-m <module-name>]\n"
" -p <perf-cmd> tuning command, both -p and - D must be chosen, with -p taking precedence.\n"
" -D <debug-cmd> debug command, both -p and - D must be chosen, with -p taking precedence.\n"
" [-S]\n"
" debug ability with an element name\n";
const std::string HELP_MSG_TEST =

View File

@ -33,6 +33,8 @@ using namespace OHOS::AppExecFwk;
namespace OHOS {
namespace AAFwk {
namespace {
size_t paramLength = 1024;
const std::string SHORT_OPTIONS = "ch:d:a:b:p:s:m:CDS";
constexpr struct option LONG_OPTIONS[] = {
{"help", no_argument, nullptr, 'h'},
@ -794,7 +796,6 @@ ErrCode AbilityManagerShellCommand::MakeWantForProcess(Want& want)
break;
}
size_t paramLength = 1024;
switch (option) {
case 'h': {
// 'aa process -h'
@ -853,12 +854,12 @@ ErrCode AbilityManagerShellCommand::MakeWantForProcess(Want& want)
}
}
if (perfCmd.empty() && debugCmd.empty()) {
HILOG_INFO("debuggablePipe aa process must contains -p or -D and param length must be less than 1024.");
result = OHOS::ERR_INVALID_VALUE;
}
if (result == OHOS::ERR_OK) {
if (perfCmd.empty() && debugCmd.empty()) {
HILOG_INFO("debuggablePipe aa process must contains -p or -D and param length must be less than 1024.");
result = OHOS::ERR_INVALID_VALUE;
}
if (abilityName.size() == 0 || bundleName.size() == 0) {
// 'aa process -a <ability-name> -b <bundle-name> [-D]'
HILOG_INFO("'aa %{public}s' without enough options.", cmd_.c_str());
@ -1127,7 +1128,11 @@ ErrCode AbilityManagerShellCommand::MakeWantFromCmd(Want& want, std::string& win
// 'aa stop-service -p xxx'
// save module name
perfCmd = optarg;
if (strlen(optarg) < paramLength) {
perfCmd = optarg;
} else {
HILOG_INFO("debuggablePipe aa start -p param length must be less than 1024.");
}
break;
}
case 'C': {