mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-19 04:49:47 -07:00
Do not try to parse request message when content-length is 0
This commit is contained in:
parent
c1f7446c26
commit
d75564b885
1 changed files with 6 additions and 1 deletions
|
@ -81,6 +81,11 @@ RequestParser::ErrorCode RequestParser::parseHttpRequest(const QByteArray& data,
|
||||||
// Parse HTTP request message
|
// Parse HTTP request message
|
||||||
if (m_request.headers.contains("content-length")) {
|
if (m_request.headers.contains("content-length")) {
|
||||||
int content_length = m_request.headers["content-length"].toInt();
|
int content_length = m_request.headers["content-length"].toInt();
|
||||||
|
if (content_length < 0) {
|
||||||
|
qWarning() << Q_FUNC_INFO << "bad request: content-length negative";
|
||||||
|
return BadRequest;
|
||||||
|
}
|
||||||
|
|
||||||
if (content_length > static_cast<int>(m_maxContentLength)) {
|
if (content_length > static_cast<int>(m_maxContentLength)) {
|
||||||
qWarning() << Q_FUNC_INFO << "bad request: message too long";
|
qWarning() << Q_FUNC_INFO << "bad request: message too long";
|
||||||
return BadRequest;
|
return BadRequest;
|
||||||
|
@ -92,7 +97,7 @@ RequestParser::ErrorCode RequestParser::parseHttpRequest(const QByteArray& data,
|
||||||
return IncompleteRequest;
|
return IncompleteRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!parseContent(content)) {
|
if ((content_length > 0) && !parseContent(content)) {
|
||||||
qWarning() << Q_FUNC_INFO << "message parsing error";
|
qWarning() << Q_FUNC_INFO << "message parsing error";
|
||||||
return BadRequest;
|
return BadRequest;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue