diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2017-10-03 15:48:18 +0100 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2017-10-03 17:36:44 +0100 |
commit | 7e7acdc32b08a56da62b8ab5ec745f8ebbc4ce2a (patch) | |
tree | 5b1a2e40787448b610a21ec4793f380c62f4b445 /src/daemon/command_parser_executor.cpp | |
parent | Merge pull request #2518 (diff) | |
download | monero-7e7acdc32b08a56da62b8ab5ec745f8ebbc4ce2a.tar.xz |
daemon: catch out of range exceptions too when calling stoll/stoi
And any other exception, just to be safe
Diffstat (limited to '')
-rw-r--r-- | src/daemon/command_parser_executor.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/daemon/command_parser_executor.cpp b/src/daemon/command_parser_executor.cpp index af46453cd..1eeb0ce9b 100644 --- a/src/daemon/command_parser_executor.cpp +++ b/src/daemon/command_parser_executor.cpp @@ -343,7 +343,7 @@ bool t_command_parser_executor::set_limit(const std::vector<std::string>& args) try { limit = std::stoll(args[0]); } - catch(const std::invalid_argument& ex) { + catch(const std::exception& ex) { std::cout << "failed to parse argument" << std::endl; return false; } @@ -363,7 +363,7 @@ bool t_command_parser_executor::set_limit_up(const std::vector<std::string>& arg try { limit = std::stoll(args[0]); } - catch(const std::invalid_argument& ex) { + catch(const std::exception& ex) { std::cout << "failed to parse argument" << std::endl; return false; } @@ -383,7 +383,7 @@ bool t_command_parser_executor::set_limit_down(const std::vector<std::string>& a try { limit = std::stoll(args[0]); } - catch(const std::invalid_argument& ex) { + catch(const std::exception& ex) { std::cout << "failed to parse argument" << std::endl; return false; } @@ -402,7 +402,7 @@ bool t_command_parser_executor::out_peers(const std::vector<std::string>& args) limit = std::stoi(args[0]); } - catch(std::invalid_argument& ex) { + catch(std::exception& ex) { _erro("stoi exception"); return false; } @@ -432,7 +432,7 @@ bool t_command_parser_executor::hard_fork_info(const std::vector<std::string>& a try { version = std::stoi(args[0]); } - catch(std::invalid_argument& ex) { + catch(std::exception& ex) { return false; } if (version <= 0 || version > 255) @@ -457,7 +457,14 @@ bool t_command_parser_executor::ban(const std::vector<std::string>& args) time_t seconds = P2P_IP_BLOCKTIME; if (args.size() > 1) { - seconds = std::stoi(args[1]); + try + { + seconds = std::stoi(args[1]); + } + catch (const std::exception &e) + { + return false; + } if (seconds == 0) { return false; |