Browse Source

add check command para size

pull/439/head
zhengyuanhua taoxiangdong 5 years ago
parent
commit
67aa9cd1c9
1 changed files with 12 additions and 1 deletions
  1. +12
    -1
      ge/graph/load/new_model_manager/model_manager.cc

+ 12
- 1
ge/graph/load/new_model_manager/model_manager.cc View File

@@ -38,7 +38,8 @@ thread_local uint32_t device_count = 0;
namespace {
const int kCmdParSize = 2;
const int kDumpCmdPairSize = 2;
const int kProfStartCmdParaSize = 2;
const std::size_t kProfCmdParaMaxSize = 1000;
const std::size_t kProfStartCmdParaSize = 2;
const std::string kCmdTypeProfile = "profile";
const std::string kCmdTypeDump = "dump";
const std::string kCmdTypeProfiling = "profiling";
@@ -751,6 +752,11 @@ Status ModelManager::HandleProfStartCommand(const Command &command) {
GELOGE(PARAM_INVALID, "When the cmd_type is 'profile start', the size of cmd_params must larger than 2.");
return PARAM_INVALID;
}
if (command.cmd_params.size() > kProfCmdParaMaxSize) {
GELOGE(PARAM_INVALID, "Command para size[%zu] larger than max[1000].", command.cmd_params.size());
return PARAM_INVALID;
}

std::map<std::string, std::string> cmd_params_map;
uint32_t step = 2;
for (uint32_t i = 0; i < command.cmd_params.size(); i += step) {
@@ -772,6 +778,11 @@ Status ModelManager::HandleProfStopCommand(const Command &command) {
GELOGE(PARAM_INVALID, "When the cmd_type is 'profile stop', the size of cmd_params must larger than 2.");
return PARAM_INVALID;
}
if (command.cmd_params.size() > kProfCmdParaMaxSize) {
GELOGE(PARAM_INVALID, "Command para size[%zu] larger than max[1000].", command.cmd_params.size());
return PARAM_INVALID;
}

std::map<std::string, std::string> cmd_params_map;
uint32_t step = 2;
for (uint32_t i = 0; i < command.cmd_params.size(); i += step) {


Loading…
Cancel
Save