mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-25 14:04:23 +00:00
Fix important Web UI bug (HTTP request parsing bug)
(cherry picked from commit bdaf16123f7c1c0b09b06e8e2cc39c700fbbcc82)
This commit is contained in:
parent
30a3110ca7
commit
b93cebacb2
@ -84,6 +84,7 @@ void HttpConnection::read() {
|
|||||||
// Parse HTTP request header
|
// Parse HTTP request header
|
||||||
int header_end = input.indexOf("\r\n\r\n");
|
int header_end = input.indexOf("\r\n\r\n");
|
||||||
if (header_end < 0) {
|
if (header_end < 0) {
|
||||||
|
qDebug() << "Partial request: \n" << input;
|
||||||
// Partial request waiting for the rest
|
// Partial request waiting for the rest
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -101,7 +102,6 @@ void HttpConnection::read() {
|
|||||||
if (m_parser.header().hasContentLength()) {
|
if (m_parser.header().hasContentLength()) {
|
||||||
const int expected_length = m_parser.header().contentLength();
|
const int expected_length = m_parser.header().contentLength();
|
||||||
QByteArray message = input.mid(header_end + 4, expected_length);
|
QByteArray message = input.mid(header_end + 4, expected_length);
|
||||||
input = input.mid(header_end + 4 + expected_length);
|
|
||||||
|
|
||||||
if (expected_length > 100000) {
|
if (expected_length > 100000) {
|
||||||
qWarning() << "Bad request: message too long";
|
qWarning() << "Bad request: message too long";
|
||||||
@ -113,10 +113,13 @@ void HttpConnection::read() {
|
|||||||
|
|
||||||
if (message.length() < expected_length) {
|
if (message.length() < expected_length) {
|
||||||
// Message too short, waiting for the rest
|
// Message too short, waiting for the rest
|
||||||
|
qDebug() << "Partial message:\n" << message;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_parser.writeMessage(message);
|
m_parser.writeMessage(message);
|
||||||
|
|
||||||
|
input = input.mid(header_end + 4 + expected_length);
|
||||||
} else {
|
} else {
|
||||||
input.clear();
|
input.clear();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user