From df50807eebb3aa25325272c426b34ac022d17f5b Mon Sep 17 00:00:00 2001 From: tastytea Date: Mon, 26 Nov 2018 05:29:39 +0100 Subject: [PATCH] Catch non-numeric size and ignore it --- src/http.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/http.cpp b/src/http.cpp index 49a3075..b6916bb 100644 --- a/src/http.cpp +++ b/src/http.cpp @@ -48,14 +48,20 @@ const Request http::parse_request(const string &request) answer = get_parameter(request, "s"); if (!answer.empty()) { - size = static_cast(std::stoul(answer)); + try + { + size = static_cast(std::stoul(answer)); + } catch (const std::exception &) {} } else { answer = get_parameter(request, "size"); if (!answer.empty()) { - size = static_cast(std::stoul(answer)); + try + { + size = static_cast(std::stoul(answer)); + } catch (const std::exception &) {} } } if (size > 512)