]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Merge r1918606 from trunk:
authorEric Covener <covener@apache.org>
Tue, 25 Jun 2024 17:29:32 +0000 (17:29 +0000)
committerEric Covener <covener@apache.org>
Tue, 25 Jun 2024 17:29:32 +0000 (17:29 +0000)
validate hostname

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1918607 13f79535-47bb-0310-9956-ffa450edef68

modules/proxy/proxy_util.c

index 3da6ebf2a1521ebb97b933aa9f2b25ca65ab037a..db1352e872fa8864a66d7820d9cb6ec219b2c71b 100644 (file)
@@ -3113,6 +3113,13 @@ ap_proxy_determine_connection(apr_pool_t *p, request_rec *r,
                              apr_pstrcat(p,"URI cannot be parsed: ", *url,
                                          NULL));
     }
+
+    if (!uri->hostname) {
+        return ap_proxyerror(r, HTTP_BAD_REQUEST,
+                             apr_pstrcat(p,"URI has no hostname: ", *url,
+                                         NULL));
+    }
+
     if (!uri->port) {
         uri->port = ap_proxy_port_of_scheme(uri->scheme);
     }
@@ -4496,6 +4503,10 @@ PROXY_DECLARE(int) ap_proxy_create_hdrbrgd(apr_pool_t *p,
 
     /* Compute Host header */
     if (dconf->preserve_host == 0) {
+        if (!uri->hostname) {
+            rc = HTTP_BAD_REQUEST;
+            goto cleanup;
+        }
         if (ap_strchr_c(uri->hostname, ':')) { /* if literal IPv6 address */
             if (uri->port_str && uri->port != DEFAULT_HTTP_PORT) {
                 host = apr_pstrcat(r->pool, "[", uri->hostname, "]:",