svn commit: r1935171 - httpd/httpd/trunk/test/modules/core

[email protected] Tue, 09 Jun 2026 16:39:57 -0000
Newsgroups gmane.comp.apache.cvs
Message-ID <178102319724.269524.7931494954410421311@svn03-he-fi>
Author: jorton
Date: Tue Jun  9 16:39:56 2026
New Revision: 1935171

Log:
* test/modules/core: Add test case for CVE_2026-43951.

Assisted-by: Claude Opus 4.6 <[email protected]>

Added:
   httpd/httpd/trunk/test/modules/core/test_006_merge_lang.py

Added: httpd/httpd/trunk/test/modules/core/test_006_merge_lang.py
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ httpd/httpd/trunk/test/modules/core/test_006_merge_lang.py	Tue Jun  9 16:39:56 2026	(r1935171)
@@ -0,0 +1,39 @@
+import os
+import pytest
+
+from pyhttpd.conf import HttpdConf
+
+
+class TestMergeLanguage:
+
+    @pytest.fixture(autouse=True, scope='class')
+    def _class_scope(self, env):
+        # Create a file with two language extensions so mod_mime
+        # populates r->content_languages with nelts == nalloc == 2.
+        doc_dir = os.path.join(env.server_dir, "htdocs", "test1")
+        with open(os.path.join(doc_dir, "doc.en.fr.html"), "w") as f:
+            f.write("Hello World\n")
+
+        conf = HttpdConf(env, extras={
+            f"test1.{env.http_tld}": """
+            AddLanguage en .en
+            AddLanguage fr .fr
+            Header set Content-Language "de, es"
+            """,
+        })
+        conf.add_vhost_test1()
+        conf.install()
+        assert env.apache_restart() == 0
+
+    # Requesting a file with two language extensions while mod_headers
+    # adds two non-matching Content-Language tokens should not crash.
+    # The merge loop in merge_response_headers must refresh its pointer
+    # to r->content_languages->elts after apr_array_push reallocates.
+    def test_core_006_01(self, env):
+        url = env.mkurl("http", "test1", "/doc.en.fr.html")
+        r = env.curl_get(url)
+        assert r.response, "no response: server may have crashed"
+        assert r.response["status"] == 200
+        cl = r.response["header"]["content-language"]
+        for lang in ["en", "fr", "de", "es"]:
+            assert lang in cl, f"expected '{lang}' in Content-Language: {cl}"