This is an automated email from the ASF dual-hosted git repository.

markt-asf pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/11.0.x by this push:
     new 770ecd5f63 Accept SETTINGS_HEADER_TABLE_SIZE values above the 
implementation limit (#1123)
770ecd5f63 is described below

commit 770ecd5f63cd56b8e48d9e68f48ed7ed5f262638
Author: Arturo Bernal <[email protected]>
AuthorDate: Fri Nov 6 16:47:17 2026 +0100

    Accept SETTINGS_HEADER_TABLE_SIZE values above the implementation limit 
(#1123)
    
    RFC 9113, section 6.5.2 defines no upper bound for 
SETTINGS_HEADER_TABLE_SIZE.
    The encoder is free to select any table size equal to or less than the
    advertised value. Tomcat was treating a value above its internal cap of
    64 KiB as a connection error (PROTOCOL_ERROR), which incorrectly terminated
    valid connections.
    
    The fix caps the stored value at the implementation limit rather than
    rejecting the setting. The HPACK encoder receives at most 
MAX_HEADER_TABLE_SIZE,
    which is always within the bound advertised by the client.
---
 .../coyote/http2/ConnectionSettingsBase.java       | 18 ++++++--------
 .../apache/coyote/http2/LocalStrings.properties    |  1 -
 .../apache/coyote/http2/LocalStrings_cs.properties |  1 -
 .../apache/coyote/http2/LocalStrings_de.properties |  1 -
 .../apache/coyote/http2/LocalStrings_es.properties |  1 -
 .../apache/coyote/http2/LocalStrings_fr.properties |  1 -
 .../apache/coyote/http2/LocalStrings_ja.properties |  1 -
 .../apache/coyote/http2/LocalStrings_ko.properties |  1 -
 .../coyote/http2/LocalStrings_zh_CN.properties     |  1 -
 .../apache/coyote/http2/TestHttp2Section_6_5.java  | 29 ++++++++++++++++++++++
 10 files changed, 37 insertions(+), 18 deletions(-)

diff --git a/java/org/apache/coyote/http2/ConnectionSettingsBase.java 
b/java/org/apache/coyote/http2/ConnectionSettingsBase.java
index 44420e1dc9..770f375d11 100644
--- a/java/org/apache/coyote/http2/ConnectionSettingsBase.java
+++ b/java/org/apache/coyote/http2/ConnectionSettingsBase.java
@@ -77,7 +77,14 @@ abstract class ConnectionSettingsBase<T extends Throwable> {
         }
 
         switch (setting) {
-            case HEADER_TABLE_SIZE -> validateHeaderTableSize(value);
+            case HEADER_TABLE_SIZE -> {
+                // RFC 9113, section 6.5.2: no protocol-defined upper bound 
exists for
+                // SETTINGS_HEADER_TABLE_SIZE; any value up to 2^32-1 is 
valid. Cap the
+                // stored value at the implementation limit rather than 
treating a large
+                // value as a protocol error.
+                set(setting, Long.valueOf(Math.min(value, 
MAX_HEADER_TABLE_SIZE)), force);
+                return;
+            }
             case ENABLE_PUSH -> validateEnablePush(value);
             case MAX_CONCURRENT_STREAMS, MAX_HEADER_LIST_SIZE -> 
validateUnsigned32BitSetting(setting, value);
             case INITIAL_WINDOW_SIZE -> validateInitialWindowSize(value);
@@ -189,15 +196,6 @@ abstract class ConnectionSettingsBase<T extends Throwable> 
{
     }
 
 
-    private void validateHeaderTableSize(long headerTableSize) throws T {
-        if (headerTableSize > MAX_HEADER_TABLE_SIZE) {
-            String msg = 
sm.getString("connectionSettings.headerTableSizeLimit", connectionId,
-                    Long.toString(headerTableSize));
-            throwException(msg, Http2Error.PROTOCOL_ERROR);
-        }
-    }
-
-
     private void validateEnablePush(long enablePush) throws T {
         // Can't be less than zero since the result of the byte->long 
conversion
         // will never be negative
diff --git a/java/org/apache/coyote/http2/LocalStrings.properties 
b/java/org/apache/coyote/http2/LocalStrings.properties
index 3a1abb7f00..de5baf5b6b 100644
--- a/java/org/apache/coyote/http2/LocalStrings.properties
+++ b/java/org/apache/coyote/http2/LocalStrings.properties
@@ -27,7 +27,6 @@ connectionPrefaceParser.mismatch=An unexpected byte sequence 
was received at the
 
 connectionSettings.debug=Connection [{0}], Endpoint [{1}], Parameter type 
[{2}] set to [{3}]
 connectionSettings.enablePushInvalid=Connection [{0}], The requested value for 
enable push [{1}] is not one of the permitted values (zero or one)
-connectionSettings.headerTableSizeLimit=Connection [{0}], Attempted to set a 
header table size of [{1}] but the limit is 16k
 connectionSettings.maxFrameSizeInvalid=Connection [{0}], The requested maximum 
frame size of [{1}] is outside the permitted range of [{2}] to [{3}]
 connectionSettings.noRfc7540PrioritiesInvalid=Connection [{0}], The requested 
no RFC 7540 priorities setting [{1}] was not zero or one
 connectionSettings.settingValueInvalid=Connection [{0}], The requested value 
[{2}] for the setting [{1}] is outside the permitted range of [{3}] to [{4}]
diff --git a/java/org/apache/coyote/http2/LocalStrings_cs.properties 
b/java/org/apache/coyote/http2/LocalStrings_cs.properties
index 0e830d36a4..a62c6b0e64 100644
--- a/java/org/apache/coyote/http2/LocalStrings_cs.properties
+++ b/java/org/apache/coyote/http2/LocalStrings_cs.properties
@@ -21,7 +21,6 @@ abstractStream.windowSizeInc=Spojení [{0}], Stream [{1}], 
zvyšte tok kontroln
 connectionPrefaceParser.mismatch=Neočekávaná sekvence bytů byla přijata při 
zahájení klientem [{0}]
 
 connectionSettings.debug=Spojení [{0}], typ parametru [{1}] nastaven na [{2}]
-connectionSettings.headerTableSizeLimit=Spojení [{0}], Pokus o nastavení 
velikosti hlavičky tabulky na [{1}], limit je však 16k
 connectionSettings.maxFrameSizeInvalid=Spojení [{0}], požadovaná maximnální 
velikost rámce  [{1}] je mimo povolený rozsah od [{2}] do [{3}]
 
 hpack.invalidCharacter=Unicode znak [{0}] na kódové značce [{1}] nemůže být 
zakódován, protože je mimo povolený rozsah 0 až 255.
diff --git a/java/org/apache/coyote/http2/LocalStrings_de.properties 
b/java/org/apache/coyote/http2/LocalStrings_de.properties
index 5924064054..4f6c7c8770 100644
--- a/java/org/apache/coyote/http2/LocalStrings_de.properties
+++ b/java/org/apache/coyote/http2/LocalStrings_de.properties
@@ -21,7 +21,6 @@ abstractStream.windowSizeInc=Verbindung [{0}], Stream [{1}], 
erhöhe Flow Contrr
 connectionPrefaceParser.mismatch=Es wurde eine unerwartete Byte Sequenz beim 
Start der Client Preface Phase [{0}] empfangen
 
 connectionSettings.debug=Verbindung [{0}], Parameter typ [{1}] gesetzt auf 
[{2}]
-connectionSettings.headerTableSizeLimit=Verbindung [{0}], versuchte die 
Kopfzeilentabellengröße auf [{1}] zu setzen aber die Grenze liegt bei 16k
 connectionSettings.maxFrameSizeInvalid=Verbindung [{0}], die angeforderte 
maximale Framegröße von [{1}] ist außerhalb des erlaubten Bereichs von [{2}] 
bis [{3}]
 
 hpack.invalidCharacter=Das Unicode Zeichen [{0}] an Code Punkt [{1}] kann 
nicht kodiert werden, da es außerhalb des erlaubten Bereiches von 0 bis 255 ist.
diff --git a/java/org/apache/coyote/http2/LocalStrings_es.properties 
b/java/org/apache/coyote/http2/LocalStrings_es.properties
index 26011f3eb0..feac238721 100644
--- a/java/org/apache/coyote/http2/LocalStrings_es.properties
+++ b/java/org/apache/coyote/http2/LocalStrings_es.properties
@@ -21,7 +21,6 @@ abstractStream.windowSizeInc=Conexión [{0}], Flujo [{1}], 
aumente el control de
 connectionPrefaceParser.mismatch=Una sequencia de byte no esperada fue 
recibida al inicio del prefacio de cliente [{0}]
 
 connectionSettings.debug=Conexión  [{0}], Parámetro tipo [{1}] fijado a [{2}]
-connectionSettings.headerTableSizeLimit=La conexión [{0}], intentó fijar un 
tamaño de cabecera de [{1}] pero el límite es  16k\n
 connectionSettings.maxFrameSizeInvalid=Conexión [{0}], El tamaño de cuadro 
máximo solicitado de [{1}] esta fuera del rango permitido de [{2}] hasta [{3}]\n
 connectionSettings.unknown=Conexión [{0}], Un parámetro desconocido con 
identificador [{1}] y valor [{2}] fue ignorado\n
 
diff --git a/java/org/apache/coyote/http2/LocalStrings_fr.properties 
b/java/org/apache/coyote/http2/LocalStrings_fr.properties
index c0f1616c43..4db55eb584 100644
--- a/java/org/apache/coyote/http2/LocalStrings_fr.properties
+++ b/java/org/apache/coyote/http2/LocalStrings_fr.properties
@@ -27,7 +27,6 @@ connectionPrefaceParser.mismatch=Une séquence inattendue 
d''octets a été recu
 
 connectionSettings.debug=Connection [{0}], Paramètre type [{1}] mis à [{2}]
 connectionSettings.enablePushInvalid=Connection [{0}], La valeur demandée pour 
activer le push [{1}] n''est pas une de celles permises (zéro ou un)
-connectionSettings.headerTableSizeLimit=La Connection [{0}] a essayé de 
configurer une taille de [{1}] pour la table des en-têtes (headers), mais la 
limite est 16k
 connectionSettings.maxFrameSizeInvalid=Connection [{0}], la taille maximum de 
trame demandée  [{1}] est en-dehors des limites permises [{2}] - [{3}]
 connectionSettings.noRfc7540PrioritiesInvalid=Connection [{0}], Le paramètre 
"no RFC 7540 priorities" [{1}] n''était pas zéro ou un
 connectionSettings.unknown=Connection [{0}], Un paramètre inconnu avec 
l''identifiant [{1}] et la valeur [{2}] a été ignoré
diff --git a/java/org/apache/coyote/http2/LocalStrings_ja.properties 
b/java/org/apache/coyote/http2/LocalStrings_ja.properties
index fce70911a3..50b371b846 100644
--- a/java/org/apache/coyote/http2/LocalStrings_ja.properties
+++ b/java/org/apache/coyote/http2/LocalStrings_ja.properties
@@ -27,7 +27,6 @@ connectionPrefaceParser.mismatch=クライアントプリフェイス [{0}] の
 
 connectionSettings.debug=コネクション [{0}]、エンドポイント [{1}]、パラメータ型 [{2}] に [{3}] 
を設定しました
 
connectionSettings.enablePushInvalid=コネクション[{0}]、有効プッシュ[{1}]にリクエストされた値が許容値(0または1)のいずれでもありません。
-connectionSettings.headerTableSizeLimit=コネクション [{0}]、ヘッダーテーブルサイズに [{1}] 
を指定されましたが上限は 16k です。
 connectionSettings.maxFrameSizeInvalid=コネクション [{0}]、要求された最大フレームサイズ [{1}] 
は可能な範囲の [{2}] から [{3}] を超えています。
 connectionSettings.noRfc7540PrioritiesInvalid=コネクション [{0}]、要求された RFC 7540 
優先度設定 [{1}] が 0 でも 1 でもありませんでした
 connectionSettings.unknown=コネクション [{0}]、未知の設定名 [{1}] の値 [{2}] を無視しました。
diff --git a/java/org/apache/coyote/http2/LocalStrings_ko.properties 
b/java/org/apache/coyote/http2/LocalStrings_ko.properties
index 9ecb85e49c..4d1e39d595 100644
--- a/java/org/apache/coyote/http2/LocalStrings_ko.properties
+++ b/java/org/apache/coyote/http2/LocalStrings_ko.properties
@@ -27,7 +27,6 @@ connectionPrefaceParser.mismatch=해당 client preface [{0}]의 시작 
부분에
 
 connectionSettings.debug=연결 [{0}]: 파라미터 타입 [{1}]을(를) [{2}](으)로 설정함.
 connectionSettings.enablePushInvalid=연결 [{0}], enablePush를 위해 요청된 값 [{1}]은(는), 
허용된 값들(0 또는 1) 중의 하나가 아닙니다.
-connectionSettings.headerTableSizeLimit=연결 [{0}]: 헤더 테이블 크기로 [{1}]을(를) 설정하려 
시도했으나, 한계값은 16k입니다.
 connectionSettings.maxFrameSizeInvalid=연결 [{0}]: [{1}]의 요청된 최대 프레임 크기가 허용된 
범위([{2}] - [{3}])의 바깥에 존재합니다.
 connectionSettings.unknown=연결 [{0}]: 식별자가 [{1}](이)고 값이 [{2}]인 알 수 없는 설정이 
무시되었습니다.
 connectionSettings.windowSizeTooBig=연결 [{0}]: 요청된 윈도우 크기 [{1}]이(가) 최대 허용치 
[{2}] 보다 큽니다.
diff --git a/java/org/apache/coyote/http2/LocalStrings_zh_CN.properties 
b/java/org/apache/coyote/http2/LocalStrings_zh_CN.properties
index d2e5dbe9d8..e8c4e38ac6 100644
--- a/java/org/apache/coyote/http2/LocalStrings_zh_CN.properties
+++ b/java/org/apache/coyote/http2/LocalStrings_zh_CN.properties
@@ -27,7 +27,6 @@ connectionPrefaceParser.mismatch=请求了新的远程流ID[{0}],但所有远
 
 connectionSettings.debug=连接[{0}],参数类型[{1}]设置为[{2}]
 connectionSettings.enablePushInvalid=连接[{0}],请求的enable push[{1}]值不是允许的值之一(零或一)
-connectionSettings.headerTableSizeLimit=连接 [{0}],尝试将 header 表大小设置为 [{1}],但限制为 
16k
 connectionSettings.maxFrameSizeInvalid=连接[{0}],请求的最大帧大小[{1}]在[{2}]到[{3}]的允许范围之外
 connectionSettings.unknown=连接[{0}],标识为[{1}]和值为[{2}]的未知设置被忽略
 connectionSettings.windowSizeTooBig=连接[{0}],请求窗口大小[{0}],大于最大允许的值[{1}]
diff --git a/test/org/apache/coyote/http2/TestHttp2Section_6_5.java 
b/test/org/apache/coyote/http2/TestHttp2Section_6_5.java
index 5992a2f200..4d6cf6dbcf 100644
--- a/test/org/apache/coyote/http2/TestHttp2Section_6_5.java
+++ b/test/org/apache/coyote/http2/TestHttp2Section_6_5.java
@@ -156,4 +156,33 @@ public class TestHttp2Section_6_5 extends Http2TestBase {
     }
 
     // delayed ACKs. Requires an API (TBD) for applications to send settings.
+
+
+    @Test
+    public void testSettingsLargeHeaderTableSize() throws Exception {
+        // RFC 9113, section 6.5.2: SETTINGS_HEADER_TABLE_SIZE has no 
protocol-defined upper
+        // bound. The encoder selects any size equal to or less than the 
advertised value.
+        // A value above the implementation limit must be accepted, not 
rejected.
+        http2Connect();
+
+        sendSettings(0, false, new SettingValue(0x1, 65537));
+
+        parser.readFrame();
+
+        Assert.assertTrue(output.getTrace(), 
output.getTrace().startsWith("0-Settings-Ack"));
+    }
+
+
+    @Test
+    public void testSettingsMaxUnsignedHeaderTableSize() throws Exception {
+        // RFC 9113, section 6.5.2: any value up to 2^32-1 is valid for
+        // SETTINGS_HEADER_TABLE_SIZE. The maximum unsigned 32-bit value must 
be accepted.
+        http2Connect();
+
+        sendSettings(0, false, new SettingValue(0x1, 0xFFFFFFFFL));
+
+        parser.readFrame();
+
+        Assert.assertTrue(output.getTrace(), 
output.getTrace().startsWith("0-Settings-Ack"));
+    }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to