Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions ixwebsocket/IXHttp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,27 @@ namespace ix
int contentLength = 0;
{
const char* p = headers["Content-Length"].c_str();
char* p_end{};
char* p_end {};
errno = 0;
long val = std::strtol(p, &p_end, 10);
if (p_end == p // invalid argument
|| errno == ERANGE // out of range
|| val < std::numeric_limits<int>::min()
|| val > std::numeric_limits<int>::max()) {
if (p_end == p // invalid argument
|| errno == ERANGE // out of range
)
{
return std::make_tuple(
false, "Error parsing HTTP Header 'Content-Length'", httpRequest);
}
contentLength = val;
if (val > std::numeric_limits<int>::max())
{
return std::make_tuple(
false, "Error: 'Content-Length' value was above max", httpRequest);
}
if (val < std::numeric_limits<int>::min())
{
return std::make_tuple(
false, "Error: 'Content-Length' value was below min", httpRequest);
}
contentLength = static_cast<int>(val);
}
if (contentLength < 0)
{
Expand Down