From c861e01300cbaef50caddda305ed87c726d6edd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Fri, 14 Jun 2024 15:38:11 +0200 Subject: [PATCH] Http2: RST: Also checking peer stream IDs for idleness MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A peer can send a RST_STREAM frame for their own stream, so we have to check if one such stream has been active instead of just our own. Change-Id: I5a46b10df98809ed3d803bfb1a92a45ab7f7d961 Reviewed-by: Øystein Heskestad Reviewed-by: Timur Pocheptsov (cherry picked from commit 0026b17eff313a0bb248a8d04593eb80f16f315d) Reviewed-by: Qt Cherry-pick Bot --- src/network/access/qhttp2connection.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/network/access/qhttp2connection.cpp b/src/network/access/qhttp2connection.cpp index eb3f9d9d8b4..d56d235bdf7 100644 --- a/src/network/access/qhttp2connection.cpp +++ b/src/network/access/qhttp2connection.cpp @@ -1329,8 +1329,12 @@ void QHttp2Connection::handleRST_STREAM() return; } - // Anything greater than m_nextStreamID has not been started yet. - if (streamID >= m_nextStreamID) { + // Verify that whatever stream is being RST'd is not in the idle state: + const quint32 lastRelevantStreamID = [this, streamID]() { + quint32 peerMask = m_connectionType == Type::Client ? 0 : 1; + return ((streamID & 1) == peerMask) ? m_lastIncomingStreamID : m_nextStreamID - 2; + }(); + if (streamID > lastRelevantStreamID) { // "RST_STREAM frames MUST NOT be sent for a stream // in the "idle" state. .. the recipient MUST treat this // as a connection error (Section 5.4.1) of type PROTOCOL_ERROR."