aboutsummaryrefslogtreecommitdiffstats
path: root/src/cli
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-09-10 20:13:17 -0400
committerJack Lloyd <[email protected]>2018-09-10 20:13:17 -0400
commit1b944cc9157e28199cac4f2ef4a01ae97a2d4201 (patch)
tree6b6288a159233c9e92f6a9ea31f9ab15e35c8501 /src/cli
parent1872f899716854927ecc68022fac318735be8824 (diff)
Better error repoting for invalid/out of range --buf-size arg
Diffstat (limited to 'src/cli')
-rw-r--r--src/cli/speed.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/cli/speed.cpp b/src/cli/speed.cpp
index f42a9fe1f..db195ac48 100644
--- a/src/cli/speed.cpp
+++ b/src/cli/speed.cpp
@@ -571,6 +571,8 @@ class Summary final
std::vector<size_t> unique_buffer_sizes(const std::string& cmdline_arg)
{
+ const size_t MAX_BUF_SIZE = 64*1024*1024;
+
std::set<size_t> buf;
for(std::string size_str : Botan::split_on(cmdline_arg, ','))
{
@@ -588,8 +590,11 @@ std::vector<size_t> unique_buffer_sizes(const std::string& cmdline_arg)
throw CLI_Usage_Error("Invalid integer value '" + size_str + "' for option buf-size");
}
- if(x == 0 || x > 16*1024*1024)
- throw CLI_Usage_Error("Invalid integer value '" + size_str + "' for option buf-size");
+ if(x == 0)
+ throw CLI_Usage_Error("Cannot have a zero-sized buffer");
+
+ if(x > MAX_BUF_SIZE)
+ throw CLI_Usage_Error("Specified buffer size is too large");
buf.insert(x);
}