From 1b944cc9157e28199cac4f2ef4a01ae97a2d4201 Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Mon, 10 Sep 2018 20:13:17 -0400 Subject: Better error repoting for invalid/out of range --buf-size arg --- src/cli/speed.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/cli') 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 unique_buffer_sizes(const std::string& cmdline_arg) { + const size_t MAX_BUF_SIZE = 64*1024*1024; + std::set buf; for(std::string size_str : Botan::split_on(cmdline_arg, ',')) { @@ -588,8 +590,11 @@ std::vector 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); } -- cgit v1.2.3