host.cpp: validate parameters before assign

This commit is contained in:
Martin Pulec
2022-07-18 10:08:23 +02:00
parent 2c155cc542
commit 5ce89a2dc9

View File

@@ -705,6 +705,11 @@ static bool parse_params(char *optarg)
char *save_ptr = nullptr;
while ((item = strtok_r(optarg, ",", &save_ptr)) != nullptr) {
char *key_cstr = item;
if (!validate_param(key_cstr)) {
LOG(LOG_LEVEL_ERROR) << "Unknown parameter: " << key_cstr << "\n";
LOG(LOG_LEVEL_INFO) << "Type '" << uv_argv[0] << " --param help' for list.\n";
return false;
}
if (strchr(item, '=') != nullptr) {
char *val_cstr = strchr(item, '=') + 1;
*strchr(item, '=') = '\0';
@@ -712,11 +717,6 @@ static bool parse_params(char *optarg)
} else {
commandline_params[key_cstr] = string();
}
if (!validate_param(key_cstr)) {
LOG(LOG_LEVEL_ERROR) << "Unknown parameter: " << key_cstr << "\n";
LOG(LOG_LEVEL_INFO) << "Type '" << uv_argv[0] << " --param help' for list.\n";
return false;
}
optarg = nullptr;
}
return true;