]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
mod_proxy: Don't mangle r->filename when ap_proxy_canon_netloc() fails.
authorYann Ylavic <ylavic@apache.org>
Mon, 8 Jul 2024 14:25:58 +0000 (14:25 +0000)
committerYann Ylavic <ylavic@apache.org>
Mon, 8 Jul 2024 14:25:58 +0000 (14:25 +0000)
ap_proxy_canon_netloc() called from canon_handler hooks modifies its given
url in pace, hence &r->filename[6] passed from ap_proxy_canon_url().

This is not an issue if every canon_handler hook succeeds (or declines)
since r->filename is usually completely rewritten finally, but on failure
it gets truncated.

Avoid this by passing a copy of r->filename from the start, the proxy *url
and r->filename don't need to point to the same data.

* proxy/proxy_util.c(ap_proxy_canon_url):
  Pass a copy of r->filename to the canon_handler hooks.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1919023 13f79535-47bb-0310-9956-ffa450edef68

modules/proxy/proxy_util.c

index a8619197c4901d0441a03a4ddfd6f1b8befa58b8..39fc7010c783b5cd93f65436c5e9be0e719ae193 100644 (file)
@@ -2561,7 +2561,7 @@ PROXY_DECLARE(int) ap_proxy_canon_url(request_rec *r)
     }
 
     /* Keep this after fixup_uds_filename() */
-    url = &r->filename[6];
+    url = ap_pstrdup(r->pool, r->filename + 6);
 
     if ((dconf->interpolate_env == 1) && (r->proxyreq == PROXYREQ_REVERSE)) {
         /* create per-request copy of reverse proxy conf,