Catch non-numeric size and ignore it

This commit is contained in:
tastytea 2018-11-26 05:29:39 +01:00
parent 69579902e2
commit df50807eeb
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
1 changed files with 8 additions and 2 deletions

View File

@ -48,14 +48,20 @@ const Request http::parse_request(const string &request)
answer = get_parameter(request, "s"); answer = get_parameter(request, "s");
if (!answer.empty()) if (!answer.empty())
{ {
size = static_cast<uint16_t>(std::stoul(answer)); try
{
size = static_cast<uint16_t>(std::stoul(answer));
} catch (const std::exception &) {}
} }
else else
{ {
answer = get_parameter(request, "size"); answer = get_parameter(request, "size");
if (!answer.empty()) if (!answer.empty())
{ {
size = static_cast<uint16_t>(std::stoul(answer)); try
{
size = static_cast<uint16_t>(std::stoul(answer));
} catch (const std::exception &) {}
} }
} }
if (size > 512) if (size > 512)