Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package qt6-httpserver for openSUSE:Factory 
checked in at 2026-11-30 14:24:23
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/qt6-httpserver (Old)
 and      /work/SRC/openSUSE:Factory/.qt6-httpserver.new.1340718 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "qt6-httpserver"

Mon Nov 30 14:24:23 2026 rev:32 rq:1400941 version:6.12.1

Changes:
--------
--- /work/SRC/openSUSE:Factory/qt6-httpserver/qt6-httpserver.changes    
2026-11-05 18:28:34.387351472 +0100
+++ 
/work/SRC/openSUSE:Factory/.qt6-httpserver.new.1340718/qt6-httpserver.changes   
    2026-11-30 14:25:21.878314088 +0100
@@ -1,0 +2,8 @@
+Tue Nov 24 13:37:14 UTC 2026 - Christophe Marin <[email protected]>
+
+- Update to 6.12.1
+  https://www.qt.io/blog/qt-6.12.1-released
+- Drop patch:
+  * CVE-2026-110944-qthttpserver-6.12-0001.diff
+
+-------------------------------------------------------------------

Old:
----
  CVE-2026-110944-qthttpserver-6.12-0001.diff
  qthttpserver-everywhere-src-6.12.0.tar.xz

New:
----
  qthttpserver-everywhere-src-6.12.1.tar.xz

----------(Old B)----------
  Old:- Drop patch:
  * CVE-2026-110944-qthttpserver-6.12-0001.diff
----------(Old E)----------

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ qt6-httpserver.spec ++++++
--- /var/tmp/diff_new_pack.kOQ4cx/_old  2026-11-30 14:25:23.653388952 +0100
+++ /var/tmp/diff_new_pack.kOQ4cx/_new  2026-11-30 14:25:23.655389037 +0100
@@ -16,7 +16,7 @@
 #
 
 
-%define real_version 6.12.0
+%define real_version 6.12.1
 %define short_version 6.12
 %define tar_name qthttpserver-everywhere-src
 %define tar_suffix %{nil}
@@ -27,14 +27,12 @@
 %endif
 #
 Name:           qt6-httpserver%{?pkg_suffix}
-Version:        6.12.0
+Version:        6.12.1
 Release:        0
 Summary:        Qt HTTP Server
 License:        GPL-3.0-only
 URL:            https://www.qt.io
 Source0:        
https://download.qt.io/official_releases/qt/%{short_version}/%{real_version}%{tar_suffix}/submodules/%{tar_name}-%{real_version}%{tar_suffix}.tar.xz
-# PATCH-FIX-UPSTREAM
-Patch0:         CVE-2026-110944-qthttpserver-6.12-0001.diff
 BuildRequires:  pkgconfig
 BuildRequires:  cmake(Qt6Concurrent) = %{real_version}
 BuildRequires:  cmake(Qt6Core) = %{real_version}

++++++ qthttpserver-everywhere-src-6.12.0.tar.xz -> 
qthttpserver-everywhere-src-6.12.1.tar.xz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/qthttpserver-everywhere-src-6.12.0/.cmake.conf 
new/qthttpserver-everywhere-src-6.12.1/.cmake.conf
--- old/qthttpserver-everywhere-src-6.12.0/.cmake.conf  2026-09-27 
12:11:39.000000000 +0200
+++ new/qthttpserver-everywhere-src-6.12.1/.cmake.conf  2026-11-16 
23:08:53.000000000 +0100
@@ -1,4 +1,4 @@
-set(QT_REPO_MODULE_VERSION "6.12.0")
+set(QT_REPO_MODULE_VERSION "6.12.1")
 set(QT_REPO_MODULE_PRERELEASE_VERSION_SEGMENT "alpha1")
 set(QT_EXTRA_INTERNAL_TARGET_DEFINES
     "QT_ENABLE_STRICT_MODE_UP_TO=QT_VERSION_CHECK(6,11,0)"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/qthttpserver-everywhere-src-6.12.0/.tag 
new/qthttpserver-everywhere-src-6.12.1/.tag
--- old/qthttpserver-everywhere-src-6.12.0/.tag 2026-09-27 12:11:39.000000000 
+0200
+++ new/qthttpserver-everywhere-src-6.12.1/.tag 2026-11-16 23:08:53.000000000 
+0100
@@ -1 +1 @@
-b9b95d5ef79f88948c6f5f6f91742cbeea8cea1e
+3ac7223ad006e96c31b9e3333e6d0012cdda7cc0
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/qthttpserver-everywhere-src-6.12.0/dependencies.yaml 
new/qthttpserver-everywhere-src-6.12.1/dependencies.yaml
--- old/qthttpserver-everywhere-src-6.12.0/dependencies.yaml    2026-09-27 
12:11:39.000000000 +0200
+++ new/qthttpserver-everywhere-src-6.12.1/dependencies.yaml    2026-11-16 
23:08:53.000000000 +0100
@@ -1,7 +1,7 @@
 dependencies:
   ../qtbase:
-    ref: 025bdad181de241e81bf853c8a2d7bf3d19261a9
+    ref: 5af1a37e31a869cd6eb8a73d82e2c71a450e6634
     required: true
   ../qtwebsockets:
-    ref: 6aedb199b5d8ee4afa4cfc956ded22bc0a2632e9
+    ref: 130f50637124ac4c490185bbc44ebed358cb36c0
     required: false
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/qthttpserver-everywhere-src-6.12.0/doc/config/qthttpserver.qdocconf 
new/qthttpserver-everywhere-src-6.12.1/doc/config/qthttpserver.qdocconf
--- old/qthttpserver-everywhere-src-6.12.0/doc/config/qthttpserver.qdocconf     
2026-09-27 12:11:39.000000000 +0200
+++ new/qthttpserver-everywhere-src-6.12.1/doc/config/qthttpserver.qdocconf     
2026-11-16 23:08:53.000000000 +0100
@@ -30,7 +30,7 @@
 qhp.QtHttpServer.indexTitle     = Qt HTTP Server
 qhp.QtHttpServer.indexRoot      =
 
-qhp.QtHttpServer.subprojects = logging examples classes
+qhp.QtHttpServer.subprojects = logging security examples classes
 
 qhp.QtHttpServer.subprojects.classes.title = C++ Classes
 qhp.QtHttpServer.subprojects.classes.indexTitle = Qt HTTP Server C++ Classes
@@ -42,9 +42,13 @@
 qhp.QtHttpServer.subprojects.examples.selectors = example
 qhp.QtHttpServer.subprojects.examples.sortPages = true
 
+qhp.QtHttpServer.subprojects.security.title = Security Considerations
+qhp.QtHttpServer.subprojects.security.indexTitle = Qt HTTP Server Security 
Considerations
+qhp.QtHttpServer.subprojects.security.selectors = none
+
 qhp.QtHttpServer.subprojects.logging.title = Logging
 qhp.QtHttpServer.subprojects.logging.indexTitle = Qt HTTP Server Logging
-qhp.QtHttpServer.subprojects.logging.selectors = group:none
+qhp.QtHttpServer.subprojects.logging.selectors = none
 
 navigation.cppclassespage = "Qt HTTP Server C++ Classes"
 navigation.landingpage = "Qt HTTP Server"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/qthttpserver-everywhere-src-6.12.0/src/httpserver/qhttpserverparser.cpp 
new/qthttpserver-everywhere-src-6.12.1/src/httpserver/qhttpserverparser.cpp
--- old/qthttpserver-everywhere-src-6.12.0/src/httpserver/qhttpserverparser.cpp 
2026-09-27 12:11:39.000000000 +0200
+++ new/qthttpserver-everywhere-src-6.12.1/src/httpserver/qhttpserverparser.cpp 
2026-11-16 23:08:53.000000000 +0100
@@ -38,6 +38,8 @@
         return QHttpServerRequest::Method::Patch;
     else if (str == "CONNECT")
         return QHttpServerRequest::Method::Connect;
+    else if (str == "TRACE")
+        return QHttpServerRequest::Method::Trace;
     else
         return QHttpServerRequest::Method::Unknown;
 }
@@ -199,12 +201,15 @@
 */
 qint64 QHttpServerParser::contentLength() const
 {
+    const QByteArray value = headerParser.firstHeaderField("content-length");
+    if (value.isEmpty())
+        return 0; // absent -> same as Content-Length: 0 (no body)
+
     bool ok = false;
-    QByteArray value = headerParser.firstHeaderField("content-length");
-    qint64 length = value.toULongLong(&ok);
-    if (ok)
-        return length;
-    return -1; // the header field is not set
+    const qulonglong length = value.toULongLong(&ok);
+    if (!ok || length > qulonglong(QByteArray::maxSize()))
+        return -1;   // invalid
+    return qint64(length);
 }
 
 /*!
@@ -270,6 +275,18 @@
         headers = headerParser.headers();
         fragment.clear(); // next fragment
 
+        // A Content-Length with more than one value (whether from repeated 
header
+        // fields or a single field carrying a comma-separated list) has 
ambiguous
+        // framing. RFC 9110 8.6 / RFC 9112 6.3.5 require rejecting differing 
values
+        // and permit rejecting identical duplicates. combinedValue() joins 
repeated
+        // fields with commas, so a comma in the result means more than one 
value.
+        if (headers.combinedValue("content-length").contains(',')) {
+            sendError(socket, QHttpServerResponder::StatusCode::BadRequest);
+            qCDebug(lcHttpServerParser) << "Multiple Content-Length values 
from client"
+                                        << getClientIpAddressAndPort();
+            return -1;
+        }
+
         if (!filter->isNumberOfHeaderFieldsAllowed(headers.size())) {
             sendError(socket, 
QHttpServerResponder::StatusCode::RequestHeaderFieldsTooLarge);
             qCDebug(lcHttpServerParser) << "Number of header fields" << 
headers.size()
@@ -308,21 +325,72 @@
         if (url.port() == -1)
             url.setPort(port);
 
-        bodyLength = contentLength(); // cache the length
+        bodyLength = contentLength();
+
+        if (bodyLength < 0) {
+            sendError(socket, QHttpServerResponder::StatusCode::BadRequest);
+            qCDebug(lcHttpServerParser) << "Invalid Content-Length from client"
+                                        << getClientIpAddressAndPort();
+            return -1;
+        }
+
         if (bodyLength > 0 && !filter->isBodySizeAllowed(bodyLength)) {
             sendError(socket, 
QHttpServerResponder::StatusCode::PayloadTooLarge);
             qCDebug(lcHttpServerParser) << "Body size too large at" << 
bodyLength
                                         << "bytes from client" << 
getClientIpAddressAndPort();
             return -1;
         }
-        // cache isChunked() since it is called often
-        // FIXME: the RFC says that anything but "identity" should be 
interpreted as chunked (4.4
-        // [2])
-        chunkedTransferEncoding = 
headerField("transfer-encoding").toLower().contains("chunked");
+
+        // Parse Transfer-Encoding as a list of transfer-codings (RFC 9112 6.1)
+        // rather than a substring match. Qt only implements the "chunked" 
coding,
+        // and it must be present exactly once as the sole coding. Every other 
case
+        // is rejected so the parser cannot disagree with an intermediary on 
how the
+        // message body is framed.
+        chunkedTransferEncoding = false;
+        const QByteArray transferEncoding = headerField("transfer-encoding");
+        if (!transferEncoding.isEmpty()) {
+            QList<QByteArray> codings;
+            const QList<QByteArray> rawCodings = transferEncoding.split(',');
+            for (QByteArray coding : rawCodings) {
+                if (const qsizetype paramStart = coding.indexOf(';'); 
paramStart != -1)
+                    coding.truncate(paramStart);
+                coding = coding.trimmed().toLower();
+                if (!coding.isEmpty())
+                    codings.append(coding);
+            }
+            if (codings.size() == 1 && codings.constFirst() == "chunked") {
+                chunkedTransferEncoding = true;
+            } else if (!codings.isEmpty()) {
+                // Either an unsupported coding, or "chunked" combined with 
another
+                // coding / not applied exactly once (it must be the sole 
coding for
+                // Qt to decode it). Reject rather than guess the framing.
+                const bool hasChunked = codings.contains("chunked");
+                sendError(socket, hasChunked
+                                  ? 
QHttpServerResponder::StatusCode::BadRequest
+                                  : 
QHttpServerResponder::StatusCode::NotImplemented);
+                qCDebug(lcHttpServerParser)
+                        << "Unsupported or malformed Transfer-Encoding from 
client"
+                        << getClientIpAddressAndPort();
+                return -1;
+            }
+        }
 
         QByteArray connectionHeaderField = headerField("connection");
         upgrade = connectionHeaderField.toLower().contains("upgrade");
 
+        // RFC 9112 6.1: a message with both Transfer-Encoding and 
Content-Length has
+        // ambiguous framing that a front-end may resolve differently (request
+        // smuggling). An origin server may reject it rather than strip the
+        // Content-Length, so reject.
+        if (!headerField("transfer-encoding").isEmpty()
+            && !headers.values("content-length").isEmpty()) {
+            sendError(socket, QHttpServerResponder::StatusCode::BadRequest);
+            qCDebug(lcHttpServerParser)
+                    << "Both Transfer-Encoding and Content-Length from client"
+                    << getClientIpAddressAndPort();
+            return -1;
+        }
+
         if (chunkedTransferEncoding || bodyLength > 0) {
             if (headerField("expect").compare("100-continue", 
Qt::CaseInsensitive) == 0)
                 state = State::ExpectContinue;
@@ -454,7 +522,7 @@
 void QHttpServerParser::clear()
 {
     headerParser.clear();
-    bodyLength = -1;
+    bodyLength = 0;
     contentRead = 0;
     chunkedTransferEncoding = false;
     lastChunkRead = false;
@@ -563,15 +631,23 @@
             }
             // Note that chunk size gets stored in currentChunkSize, what is 
returned is the bytes
             // read
-            bytes += getChunkSize(socket, &currentChunkSize);
+            const qsizetype chunkSizeBytes = getChunkSize(socket, 
&currentChunkSize);
+            if (chunkSizeBytes < 0)
+                return -1;
+            bytes += chunkSizeBytes;
             if (currentChunkSize == -1)
                 break;
-            if (!filter->isBodySizeAllowed(bodyBuffer.byteAmount() + 
currentChunkSize)) {
+            qsizetype projectedBodySize = 0;
+            if (qAddOverflow(qsizetype(bodyBuffer.byteAmount()), 
currentChunkSize,
+                             &projectedBodySize)
+                || !filter->isBodySizeAllowed(projectedBodySize)) {
+
                 sendError(socket, 
QHttpServerResponder::StatusCode::PayloadTooLarge);
                 socket->skip(socket->bytesAvailable());
-                qCDebug(lcHttpServerParser) << "Body size too large currently 
at"
-                                            << (bodyBuffer.byteAmount() + 
currentChunkSize)
-                                            << "from client" << 
getClientIpAddressAndPort();
+                qCDebug(lcHttpServerParser) << "Body size too large; running 
total"
+                                            << bodyBuffer.byteAmount() << "+ 
chunk"
+                                            << currentChunkSize << "from 
client"
+                                            << getClientIpAddressAndPort();
                 return -1;
             }
         }
@@ -628,11 +704,22 @@
             bytes += socket->read(crlf, 1); // read the \r or \n
             if (crlf[0] == '\r')
                 bytes += socket->read(crlf, 1); // read the \n
-            bool ok = false;
+
             // ignore the chunk-extension
-            fragment = fragment.mid(0, fragment.indexOf(';')).trimmed();
-            *chunkSize = fragment.toLong(&ok, 16);
+            QByteArrayView sizeField = fragment;
+            if (const qsizetype pos = sizeField.indexOf(';'); pos != -1)
+                sizeField = sizeField.first(pos);
+            bool ok = false;
+            const qulonglong parsed = sizeField.trimmed().toULongLong(&ok, 16);
             fragment.clear();
+            if (!ok || parsed > qulonglong(QByteArray::maxSize())) {
+                sendError(socket, 
QHttpServerResponder::StatusCode::BadRequest);
+                socket->skip(socket->bytesAvailable());
+                qCDebug(lcHttpServerParser) << "Invalid chunk size from client"
+                                            << getClientIpAddressAndPort();
+                return -1; // hard failure -> caller closes the connection
+            }
+            *chunkSize = qsizetype(parsed);
             break; // size done
         } else {
             // read the fragment to the buffer
@@ -643,6 +730,14 @@
 
             bytes += haveRead;
             fragment.append(c);
+            if (!filter->isHeaderFieldSizeAllowed(fragment.size())) {
+                sendError(socket, 
QHttpServerResponder::StatusCode::BadRequest);
+                socket->skip(socket->bytesAvailable());
+                qCDebug(lcHttpServerParser) << "Chunk size line too long at" 
<< fragment.size()
+                                            << "bytes from client" << 
getClientIpAddressAndPort();
+                fragment.clear();
+                return -1;
+            }
         }
     }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/qthttpserver-everywhere-src-6.12.0/tests/auto/qabstracthttpserver/tst_qabstracthttpserver.cpp
 
new/qthttpserver-everywhere-src-6.12.1/tests/auto/qabstracthttpserver/tst_qabstracthttpserver.cpp
--- 
old/qthttpserver-everywhere-src-6.12.0/tests/auto/qabstracthttpserver/tst_qabstracthttpserver.cpp
   2026-09-27 12:11:39.000000000 +0200
+++ 
new/qthttpserver-everywhere-src-6.12.1/tests/auto/qabstracthttpserver/tst_qabstracthttpserver.cpp
   2026-11-16 23:08:53.000000000 +0100
@@ -154,6 +154,20 @@
     void http2request();
     void socketDisconnected();
     void keepAliveTimeout();
+    void chunkedRequest();
+    void chunkedSizeLineTooLong();
+    void chunkedInvalidSize_data();
+    void chunkedInvalidSize();
+    void chunkedBodySizeOverflow();
+    void contentLengthOverflow_data();
+    void contentLengthOverflow();
+    void invalidTransferEncoding_data();
+    void invalidTransferEncoding();
+    void multipleContentLength_data();
+    void multipleContentLength();
+    void contentLengthAndTransferEncoding_data();
+    void contentLengthAndTransferEncoding();
+    void totalHeaderSizeLimit();
 
 private:
 #if QT_CONFIG(ssl)
@@ -990,6 +1004,434 @@
 #endif // QT_CONFIG(ssl)
 }
 
+void tst_QAbstractHttpServer::chunkedRequest()
+{
+    struct HttpServer : QAbstractHttpServer
+    {
+        QByteArray body;
+        bool handleRequest(const QHttpServerRequest &request,
+                           QHttpServerResponder &responder) override
+        {
+            body = request.body();
+            auto _responder = std::move(responder);
+            return true;
+        }
+
+        void missingHandler(const QHttpServerRequest &, QHttpServerResponder 
&) override { }
+    } server;
+
+    QTcpServer tcpServer;
+    QVERIFY(tcpServer.listen());
+    server.bind(&tcpServer);
+
+    QTcpSocket client;
+    client.connectToHost(QHostAddress::LocalHost, tcpServer.serverPort());
+    QVERIFY(client.waitForConnected());
+
+    // A well-formed chunked request body must be decoded and delivered.
+    client.write("POST / HTTP/1.1\r\n"
+                 "Host: localhost\r\n"
+                 "Transfer-Encoding: chunked\r\n"
+                 "\r\n"
+                 "5\r\nHello\r\n"
+                 "6\r\n World\r\n"
+                 "0\r\n\r\n");
+    QVERIFY(client.waitForBytesWritten());
+
+    QTRY_COMPARE(server.body, QByteArray("Hello World"));
+}
+
+void tst_QAbstractHttpServer::chunkedSizeLineTooLong()
+{
+    struct HttpServer : QAbstractHttpServer
+    {
+        bool handleRequestCalled = false;
+        bool handleRequest(const QHttpServerRequest &, QHttpServerResponder 
&responder) override
+        {
+            handleRequestCalled = true;
+            auto _responder = std::move(responder);
+            return true;
+        }
+
+        void missingHandler(const QHttpServerRequest &, QHttpServerResponder 
&) override { }
+    } server;
+
+    QTcpServer tcpServer;
+    QVERIFY(tcpServer.listen());
+    server.bind(&tcpServer);
+
+    // Lower the per-field limit (default 48 KiB) so a few hundred bytes trip 
the
+    // size-line cap
+    QHttpServerConfiguration config;
+    config.setMaximumHeaderFieldSize(256);
+    server.setConfiguration(config);
+
+    QTcpSocket client;
+    client.connectToHost(QHostAddress::LocalHost, tcpServer.serverPort());
+    QVERIFY(client.waitForConnected());
+
+    // Send a chunk-size line that never terminates: a run of digits with no 
CRLF.
+    // This is not a valid chunk. The parser must bound the size-line buffer,
+    // reply 400, and close.
+    QByteArray request = "POST / HTTP/1.1\r\n"
+                         "Host: localhost\r\n"
+                         "Transfer-Encoding: chunked\r\n"
+                         "\r\n";
+    request += QByteArray(512, '0'); // exceeds the 256-byte size-line cap, no 
CRLF
+    client.write(request);
+    QVERIFY(client.waitForBytesWritten());
+
+    // waitForDisconnected() would only wait on the client socket and time out
+    QTRY_COMPARE(client.state(), QAbstractSocket::UnconnectedState);
+    const QByteArray response = client.readAll();
+    QVERIFY2(response.startsWith("HTTP/1.1 400"), response.constData());
+    QVERIFY(!server.handleRequestCalled);
+}
+
+void tst_QAbstractHttpServer::chunkedInvalidSize_data()
+{
+    QTest::addColumn<QByteArray>("chunkSizeLine");
+
+    // Fits quint64 but exceeds qsizetype: parses, then fails the range check.
+    QTest::addRow("uint64-max") << QByteArray("ffffffffffffffff");
+    QTest::addRow("above-int64-max") << QByteArray("8000000000000000");
+    // Fails to parse: toULongLong() rejects a leading '-', and non-hex digits.
+    QTest::addRow("negative") << QByteArray("-2");
+    QTest::addRow("non-hex") << QByteArray("zz");
+}
+
+void tst_QAbstractHttpServer::chunkedInvalidSize()
+{
+    QFETCH(QByteArray, chunkSizeLine);
+
+    struct HttpServer : QAbstractHttpServer
+    {
+        bool handleRequestCalled = false;
+        bool handleRequest(const QHttpServerRequest &, QHttpServerResponder 
&responder) override
+        {
+            handleRequestCalled = true;
+            auto _responder = std::move(responder);
+            return true;
+        }
+
+        void missingHandler(const QHttpServerRequest &, QHttpServerResponder 
&) override { }
+    } server;
+
+    QTcpServer tcpServer;
+    QVERIFY(tcpServer.listen());
+    server.bind(&tcpServer);
+
+    QTcpSocket client;
+    client.connectToHost(QHostAddress::LocalHost, tcpServer.serverPort());
+    QVERIFY(client.waitForConnected());
+
+    // A malformed or out-of-range chunk size must be rejected with 400 and the
+    // connection closed.
+    QByteArray request = "POST / HTTP/1.1\r\n"
+                         "Host: localhost\r\n"
+                         "Transfer-Encoding: chunked\r\n"
+                         "\r\n";
+    request += chunkSizeLine + "\r\n";
+    client.write(request);
+    QVERIFY(client.waitForBytesWritten());
+
+    // waitForDisconnected() would only wait on the client socket and time out
+    QTRY_COMPARE(client.state(), QAbstractSocket::UnconnectedState);
+    const QByteArray response = client.readAll();
+    QVERIFY2(response.startsWith("HTTP/1.1 400"), response.constData());
+    QVERIFY(!server.handleRequestCalled);
+}
+
+void tst_QAbstractHttpServer::chunkedBodySizeOverflow()
+{
+    struct HttpServer : QAbstractHttpServer
+    {
+        bool handleRequestCalled = false;
+        bool handleRequest(const QHttpServerRequest &, QHttpServerResponder 
&responder) override
+        {
+            handleRequestCalled = true;
+            auto _responder = std::move(responder);
+            return true;
+        }
+
+        void missingHandler(const QHttpServerRequest &, QHttpServerResponder 
&) override { }
+    } server;
+
+    QTcpServer tcpServer;
+    QVERIFY(tcpServer.listen());
+    server.bind(&tcpServer);
+
+    QTcpSocket client;
+    client.connectToHost(QHostAddress::LocalHost, tcpServer.serverPort());
+    QVERIFY(client.waitForConnected());
+
+    // First chunk carries 64 bytes so the running total exceeds the small gap
+    // between QByteArray::maxSize() and the qsizetype maximum. The second 
chunk
+    // then announces QByteArray::maxSize() (the largest size that passes 
per-chunk
+    // validation) so the cumulative total (64 + maxSize) overflows the sum. 
The
+    // parser must catch that and reply 413 rather than let it wrap past the 
limit.
+    const QByteArray maxSizeChunk = QByteArray::number(QByteArray::maxSize(), 
16);
+    QByteArray request = "POST / HTTP/1.1\r\n"
+                         "Host: localhost\r\n"
+                         "Transfer-Encoding: chunked\r\n"
+                         "\r\n";
+    request += "40\r\n" + QByteArray(64, 'X') + "\r\n"; // 0x40 = 64-byte 
first chunk
+    request += maxSizeChunk + "\r\n";                   // == 
QByteArray::maxSize()
+    client.write(request);
+    QVERIFY(client.waitForBytesWritten());
+
+    // waitForDisconnected() would only wait on the client socket and time out
+    QTRY_COMPARE(client.state(), QAbstractSocket::UnconnectedState);
+    const QByteArray response = client.readAll();
+    QVERIFY2(response.startsWith("HTTP/1.1 413"), response.constData());
+    QVERIFY(!server.handleRequestCalled);
+}
+
+void tst_QAbstractHttpServer::contentLengthOverflow_data()
+{
+    QTest::addColumn<QByteArray>("contentLength");
+    QTest::addRow("uint64-max")       << QByteArray("18446744073709551615");
+    QTest::addRow("int64-max-plus-1") << QByteArray("9223372036854775808");
+    QTest::addRow("int64-max-plus-2") << QByteArray("9223372036854775809");
+#if QT_POINTER_SIZE == 4
+    QTest::addRow("int32-max-plus-1") << QByteArray("2147483648");
+#endif
+}
+
+void tst_QAbstractHttpServer::contentLengthOverflow()
+{
+    QFETCH(QByteArray, contentLength);
+
+    struct HttpServer : QAbstractHttpServer
+    {
+        bool handleRequestCalled = false;
+        bool handleRequest(const QHttpServerRequest &, QHttpServerResponder 
&responder) override
+        {
+            handleRequestCalled = true;
+            auto _responder = std::move(responder);
+            return true;
+        }
+
+        void missingHandler(const QHttpServerRequest &, QHttpServerResponder 
&) override { }
+    } server;
+
+    QTcpServer tcpServer;
+    QVERIFY(tcpServer.listen());
+    server.bind(&tcpServer);
+
+    QTcpSocket client;
+    client.connectToHost(QHostAddress::LocalHost, tcpServer.serverPort());
+    QVERIFY(client.waitForConnected());
+
+    QByteArray request = "POST / HTTP/1.1\r\n"
+                         "Host: localhost\r\n"
+                         "Content-Length:" + contentLength + "\r\n"
+                         "\r\n";
+    client.write(request);
+    QVERIFY(client.waitForBytesWritten());
+
+    // waitForDisconnected() would only wait on the client socket and time out
+    QTRY_COMPARE(client.state(), QAbstractSocket::UnconnectedState);
+    const QByteArray response = client.readAll();
+    QVERIFY2(response.startsWith("HTTP/1.1 400"), response.constData());
+    QVERIFY(!server.handleRequestCalled);
+}
+
+void tst_QAbstractHttpServer::invalidTransferEncoding_data()
+{
+    QTest::addColumn<QByteArray>("transferEncoding");
+    QTest::addColumn<int>("statusCode");
+
+    // A coding other than "chunked" is unsupported -> 501 Not Implemented.
+    QTest::addRow("gzip")            << QByteArray("gzip")             << 501;
+    QTest::addRow("identity")        << QByteArray("identity")         << 501;
+    QTest::addRow("xchunked")        << QByteArray("xchunked")         << 501; 
// not the "chunked" token
+    // "chunked" combined with another coding, or repeated -> malformed, 400.
+    QTest::addRow("gzip,chunked")    << QByteArray("gzip, chunked")    << 400;
+    QTest::addRow("chunked,gzip")    << QByteArray("chunked, gzip")    << 400;
+    QTest::addRow("chunked,chunked") << QByteArray("chunked, chunked") << 400;
+}
+
+void tst_QAbstractHttpServer::invalidTransferEncoding()
+{
+    QFETCH(QByteArray, transferEncoding);
+    QFETCH(int, statusCode);
+
+    struct HttpServer : QAbstractHttpServer
+    {
+        bool handleRequestCalled = false;
+        bool handleRequest(const QHttpServerRequest &, QHttpServerResponder 
&responder) override
+        {
+            handleRequestCalled = true;
+            auto _responder = std::move(responder);
+            return true;
+        }
+
+        void missingHandler(const QHttpServerRequest &, QHttpServerResponder 
&) override { }
+    } server;
+
+    QTcpServer tcpServer;
+    QVERIFY(tcpServer.listen());
+    server.bind(&tcpServer);
+
+    QTcpSocket client;
+    client.connectToHost(QHostAddress::LocalHost, tcpServer.serverPort());
+    QVERIFY(client.waitForConnected());
+
+    const QByteArray request = "POST / HTTP/1.1\r\n"
+                               "Host: localhost\r\n"
+                               "Transfer-Encoding: " + transferEncoding + 
"\r\n"
+                               "\r\n";
+    client.write(request);
+    QVERIFY(client.waitForBytesWritten());
+
+    // waitForDisconnected() would only wait on the client socket and time out
+    QTRY_COMPARE(client.state(), QAbstractSocket::UnconnectedState);
+    const QByteArray response = client.readAll();
+    const QByteArray expected = "HTTP/1.1 " + QByteArray::number(statusCode);
+    QVERIFY2(response.startsWith(expected), response.constData());
+    QVERIFY(!server.handleRequestCalled);
+}
+
+void tst_QAbstractHttpServer::multipleContentLength_data()
+{
+    QTest::addColumn<QByteArray>("contentLengthHeaders");
+    QTest::addRow("two-differing-fields")
+        << QByteArray("Content-Length: 5\r\nContent-Length: 6\r\n");
+    QTest::addRow("two-identical-fields")
+        << QByteArray("Content-Length: 5\r\nContent-Length: 5\r\n");
+    QTest::addRow("list-identical")   // Thiago's case
+        << QByteArray("Content-Length: 123, 123, 123, 123\r\n");
+    QTest::addRow("list-differing")
+        << QByteArray("Content-Length: 5, 6\r\n");
+}
+
+void tst_QAbstractHttpServer::multipleContentLength()
+{
+    QFETCH(QByteArray, contentLengthHeaders);
+
+    struct HttpServer : QAbstractHttpServer
+    {
+        bool handleRequestCalled = false;
+        bool handleRequest(const QHttpServerRequest &, QHttpServerResponder 
&responder) override
+        {
+            handleRequestCalled = true;
+            auto _responder = std::move(responder);
+            return true;
+        }
+        void missingHandler(const QHttpServerRequest &, QHttpServerResponder 
&) override { }
+    } server;
+
+    QTcpServer tcpServer;
+    QVERIFY(tcpServer.listen());
+    server.bind(&tcpServer);
+
+    QTcpSocket client;
+    client.connectToHost(QHostAddress::LocalHost, tcpServer.serverPort());
+    QVERIFY(client.waitForConnected());
+
+    const QByteArray request = "POST / HTTP/1.1\r\n"
+                               "Host: localhost\r\n"
+                               + contentLengthHeaders +
+                               "\r\n";
+    client.write(request);
+    QVERIFY(client.waitForBytesWritten());
+
+    // waitForDisconnected() would only wait on the client socket and time out
+    QTRY_COMPARE(client.state(), QAbstractSocket::UnconnectedState);
+    const QByteArray response = client.readAll();
+    QVERIFY2(response.startsWith("HTTP/1.1 400"), response.constData());
+    QVERIFY(!server.handleRequestCalled);
+}
+
+void tst_QAbstractHttpServer::contentLengthAndTransferEncoding_data()
+{
+    QTest::addColumn<QByteArray>("headers");
+    QTest::addRow("cl-then-te")
+        << QByteArray("Content-Length: 5\r\nTransfer-Encoding: chunked\r\n");
+    QTest::addRow("te-then-cl")
+        << QByteArray("Transfer-Encoding: chunked\r\nContent-Length: 5\r\n");
+}
+
+void tst_QAbstractHttpServer::contentLengthAndTransferEncoding()
+{
+    QFETCH(QByteArray, headers);
+
+    struct HttpServer : QAbstractHttpServer
+    {
+        bool handleRequestCalled = false;
+        bool handleRequest(const QHttpServerRequest &, QHttpServerResponder 
&responder) override
+        {
+            handleRequestCalled = true;
+            auto _responder = std::move(responder);
+            return true;
+        }
+        void missingHandler(const QHttpServerRequest &, QHttpServerResponder 
&) override { }
+    } server;
+
+    QTcpServer tcpServer;
+    QVERIFY(tcpServer.listen());
+    server.bind(&tcpServer);
+
+    QTcpSocket client;
+    client.connectToHost(QHostAddress::LocalHost, tcpServer.serverPort());
+    QVERIFY(client.waitForConnected());
+
+    const QByteArray request = "POST / HTTP/1.1\r\n"
+                               "Host: localhost\r\n"
+                               + headers +
+                               "\r\n";
+    client.write(request);
+    QVERIFY(client.waitForBytesWritten());
+
+    // waitForDisconnected() would only wait on the client socket and time out
+    QTRY_COMPARE(client.state(), QAbstractSocket::UnconnectedState);
+    const QByteArray response = client.readAll();
+    QVERIFY2(response.startsWith("HTTP/1.1 400"), response.constData());
+    QVERIFY(!server.handleRequestCalled);
+}
+
+void tst_QAbstractHttpServer::totalHeaderSizeLimit()
+{
+    struct HttpServer : QAbstractHttpServer
+    {
+        bool handleRequestCalled = false;
+        bool handleRequest(const QHttpServerRequest &, QHttpServerResponder 
&responder) override
+        {
+            handleRequestCalled = true;
+            auto _responder = std::move(responder);
+            return true;
+        }
+        void missingHandler(const QHttpServerRequest &, QHttpServerResponder 
&) override { }
+    } server;
+
+    QTcpServer tcpServer;
+    QVERIFY(tcpServer.listen());
+    server.bind(&tcpServer);
+
+    // Lower the total-header limit; each field stays well under the per-field
+    // limit, so only the *total* triggers rejection.
+    QHttpServerConfiguration config;
+    config.setMaximumTotalHeaderSize(1024);
+    server.setConfiguration(config);
+
+    QTcpSocket client;
+    client.connectToHost(QHostAddress::LocalHost, tcpServer.serverPort());
+    QVERIFY(client.waitForConnected());
+
+    QByteArray request = "GET / HTTP/1.1\r\nHost: localhost\r\n";
+    for (int i = 0; i < 100; ++i) // ~100 small fields -> a few KB total, > 1 
KB
+        request += "X-Custom-Header-" + QByteArray::number(i) + ": value\r\n";
+    request += "\r\n";
+    client.write(request);
+    QVERIFY(client.waitForBytesWritten());
+
+    QTRY_COMPARE(client.state(), QAbstractSocket::UnconnectedState);
+    const QByteArray response = client.readAll();
+    QVERIFY2(response.startsWith("HTTP/1.1 431"), response.constData());
+    QVERIFY(!server.handleRequestCalled);
+}
+
 QT_END_NAMESPACE
 
 QTEST_MAIN(tst_QAbstractHttpServer)

Reply via email to