diff options
-rw-r--r-- | src/websockets/qwebsocket_p.cpp | 2 | ||||
-rw-r--r-- | src/websockets/qwebsocket_p.h | 6 | ||||
-rw-r--r-- | src/websockets/qwebsocketserver_p.cpp | 11 |
3 files changed, 9 insertions, 10 deletions
diff --git a/src/websockets/qwebsocket_p.cpp b/src/websockets/qwebsocket_p.cpp index f08bf3b..9fef0c3 100644 --- a/src/websockets/qwebsocket_p.cpp +++ b/src/websockets/qwebsocket_p.cpp @@ -37,8 +37,6 @@ QT_BEGIN_NAMESPACE namespace { -constexpr int MAX_HEADERLINE_LENGTH = 8 * 1024; // maximum length of a http request header line -constexpr int MAX_HEADERLINES = 100; // maximum number of http request header lines constexpr quint64 MAX_OUTGOING_FRAME_SIZE_IN_BYTES = std::numeric_limits<int>::max() - 1; constexpr quint64 DEFAULT_OUTGOING_FRAME_SIZE_IN_BYTES = 512 * 512 * 2; // default size of a frame when sending a message diff --git a/src/websockets/qwebsocket_p.h b/src/websockets/qwebsocket_p.h index 08be774..e78970d 100644 --- a/src/websockets/qwebsocket_p.h +++ b/src/websockets/qwebsocket_p.h @@ -75,6 +75,12 @@ public: QWebSocketProtocol::Version version); ~QWebSocketPrivate() override; + // both constants are taken from the default settings of Apache + // see: http://httpd.apache.org/docs/2.2/mod/core.html#limitrequestfieldsize and + // http://httpd.apache.org/docs/2.2/mod/core.html#limitrequestfields + static constexpr int MAX_HEADERLINE_LENGTH = 8 * 1024; // maximum length of a http request header line + static constexpr int MAX_HEADERLINES = 100; // maximum number of http request header lines + void init(); void abort(); QAbstractSocket::SocketError error() const; diff --git a/src/websockets/qwebsocketserver_p.cpp b/src/websockets/qwebsocketserver_p.cpp index a0afd10..c8a2e87 100644 --- a/src/websockets/qwebsocketserver_p.cpp +++ b/src/websockets/qwebsocketserver_p.cpp @@ -21,12 +21,6 @@ QT_BEGIN_NAMESPACE -//both constants are taken from the default settings of Apache -//see: http://httpd.apache.org/docs/2.2/mod/core.html#limitrequestfieldsize and -//http://httpd.apache.org/docs/2.2/mod/core.html#limitrequestfields -const int MAX_HEADERLINE_LENGTH = 8 * 1024; //maximum length of a http request header line -const int MAX_HEADERLINES = 100; //maximum number of http request header lines - /*! \internal */ @@ -455,7 +449,8 @@ void QWebSocketServerPrivate::handshakeReceived() if (endOfHeaderIndex < 0) { //then we don't have our header complete yet //check that no one is trying to exhaust our virtual memory - const qint64 maxHeaderLength = MAX_HEADERLINE_LENGTH * MAX_HEADERLINES + endOfHeaderMarker.size(); + const qint64 maxHeaderLength = QWebSocketPrivate::MAX_HEADERLINE_LENGTH + * QWebSocketPrivate::MAX_HEADERLINES + endOfHeaderMarker.size(); if (Q_UNLIKELY(byteAvailable > maxHeaderLength)) { pTcpSocket->close(); setError(QWebSocketProtocol::CloseCodeTooMuchData, @@ -490,7 +485,7 @@ void QWebSocketServerPrivate::handshakeReceived() } QWebSocketHandshakeRequest request(pTcpSocket->peerPort(), isSecure); - request.readHandshake(header, MAX_HEADERLINE_LENGTH); + request.readHandshake(header, QWebSocketPrivate::MAX_HEADERLINE_LENGTH); if (request.isValid()) { QWebSocketCorsAuthenticator corsAuthenticator(request.origin()); |