Skip to content
Snippets Groups Projects
Commit 6ed21a4a authored by Michael Davis's avatar Michael Davis
Browse files

[cta-admin] Check that uint64 arguments are not negative numbers

parent 1cb2013a
No related branches found
No related tags found
No related merge requests found
...@@ -363,9 +363,11 @@ void CtaAdminCmd::addOption(const Option &option, const std::string &value) ...@@ -363,9 +363,11 @@ void CtaAdminCmd::addOption(const Option &option, const std::string &value)
} }
case Option::OPT_UINT: try { case Option::OPT_UINT: try {
auto key = uint64Options.at(option.get_key()); auto key = uint64Options.at(option.get_key());
int64_t val_int = std::stol(value);
if(val_int < 0) throw std::out_of_range("value is negative");
auto new_opt = admincmd_ptr->add_option_uint64(); auto new_opt = admincmd_ptr->add_option_uint64();
new_opt->set_key(key); new_opt->set_key(key);
new_opt->set_value(std::stoul(value)); new_opt->set_value(val_int);
break; break;
} catch(std::invalid_argument &) { } catch(std::invalid_argument &) {
throw std::runtime_error(value + " is not a valid uint64: " + option.help()); throw std::runtime_error(value + " is not a valid uint64: " + option.help());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment