StatusLine::parse: only feed integers to std::atoi()

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I7591fd14fbdc7c1210ac8141cb78854e3f20fffd
pull/2122/head
Miklos Vajna 2021-04-23 09:43:34 +02:00
parent 9e331465d9
commit 415a834813
2 changed files with 7 additions and 0 deletions

View File

@ -0,0 +1,2 @@
HTTP/1.1

View File

@ -225,6 +225,11 @@ FieldParseState StatusLine::parse(const char* p, int64_t& len)
// Read the Status Code now.
assert(off + StatusCodeLen < len && "Expected to have more data.");
if (p[off] < '0' || p[off] > '9')
{
LOG_ERR("StatusLine::parse: expected valid integer number");
return FieldParseState::Invalid;
}
_statusCode = std::atoi(&p[off]);
if (_statusCode < MinValidStatusCode || _statusCode > MaxValidStatusCode)
{