692b48
diff --git a/modules/mappers/mod_rewrite.c b/modules/mappers/mod_rewrite.c
692b48
index fb897a9..38dbb24 100644
692b48
--- a/modules/mappers/mod_rewrite.c
692b48
+++ b/modules/mappers/mod_rewrite.c
692b48
@@ -619,6 +619,13 @@ static unsigned is_absolute_uri(char *uri, int *supportsqs)
692b48
             return 6;
692b48
         }
692b48
         break;
692b48
+
692b48
+    case 'u':
692b48
+    case 'U':
692b48
+        if (!ap_cstr_casecmpn(uri, "nix:", 4)) {        /* unix:     */
692b48
+            *sqs = 1;
692b48
+            return (uri[4] == '/' && uri[5] == '/') ? 7 : 5;
692b48
+        }
692b48
     }
692b48
 
692b48
     return 0;
692b48
diff --git a/modules/proxy/mod_proxy.c b/modules/proxy/mod_proxy.c
692b48
index f383996..6a9ef55 100644
692b48
--- a/modules/proxy/mod_proxy.c
692b48
+++ b/modules/proxy/mod_proxy.c
692b48
@@ -1717,7 +1717,8 @@ PROXY_DECLARE(const char *) ap_proxy_de_socketfy(apr_pool_t *p, const char *url)
692b48
      * the UDS path... ignore it
692b48
      */
692b48
     if (!strncasecmp(url, "unix:", 5) &&
692b48
-        ((ptr = ap_strchr_c(url, '|')) != NULL)) {
692b48
+        ((ptr = ap_strchr_c(url + 5, '|')) != NULL)) {
692b48
+
692b48
         /* move past the 'unix:...|' UDS path info */
692b48
         const char *ret, *c;
692b48
 
692b48
diff --git a/modules/proxy/proxy_util.c b/modules/proxy/proxy_util.c
692b48
index 7714b6c..3dd570c 100644
692b48
--- a/modules/proxy/proxy_util.c
692b48
+++ b/modules/proxy/proxy_util.c
692b48
@@ -2084,33 +2084,45 @@ static int ap_proxy_retry_worker(const char *proxy_function, proxy_worker *worke
692b48
  * were passed a UDS url (eg: from mod_proxy) and adjust uds_path
692b48
  * as required.  
692b48
  */
692b48
-static void fix_uds_filename(request_rec *r, char **url) 
692b48
+static int fix_uds_filename(request_rec *r, char **url) 
692b48
 {
692b48
-    char *ptr, *ptr2;
692b48
-    if (!r || !r->filename) return;
692b48
+    char *uds_url = r->filename + 6, *origin_url;
692b48
 
692b48
     if (!strncmp(r->filename, "proxy:", 6) &&
692b48
-            (ptr2 = ap_strcasestr(r->filename, "unix:")) &&
692b48
-            (ptr = ap_strchr(ptr2, '|'))) {
692b48
+            !ap_cstr_casecmpn(uds_url, "unix:", 5) &&
692b48
+            (origin_url = ap_strchr(uds_url + 5, '|'))) {
692b48
+        char *uds_path = NULL;
692b48
+        apr_size_t url_len;
692b48
         apr_uri_t urisock;
692b48
         apr_status_t rv;
692b48
-        *ptr = '\0';
692b48
-        rv = apr_uri_parse(r->pool, ptr2, &urisock);
692b48
-        if (rv == APR_SUCCESS) {
692b48
-            char *rurl = ptr+1;
692b48
-            char *sockpath = ap_runtime_dir_relative(r->pool, urisock.path);
692b48
-            apr_table_setn(r->notes, "uds_path", sockpath);
692b48
-            *url = apr_pstrdup(r->pool, rurl); /* so we get the scheme for the uds */
692b48
-            /* r->filename starts w/ "proxy:", so add after that */
692b48
-            memmove(r->filename+6, rurl, strlen(rurl)+1);
692b48
-            ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, r,
692b48
-                    "*: rewrite of url due to UDS(%s): %s (%s)",
692b48
-                    sockpath, *url, r->filename);
692b48
-        }
692b48
-        else {
692b48
-            *ptr = '|';
692b48
-        }
692b48
-    }
692b48
+
692b48
+        *origin_url = '\0';
692b48
+        rv = apr_uri_parse(r->pool, uds_url, &urisock);
692b48
+        *origin_url++ = '|';
692b48
+
692b48
+        if (rv == APR_SUCCESS && urisock.path && (!urisock.hostname
692b48
+                                                  || !urisock.hostname[0])) {
692b48
+             uds_path = ap_runtime_dir_relative(r->pool, urisock.path);
692b48
+        }
692b48
+
692b48
+        if (!uds_path) {
692b48
+             ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(10292)
692b48
+                     "Invalid proxy UDS filename (%s)", r->filename);
692b48
+             return 0;
692b48
+        }
692b48
+        apr_table_setn(r->notes, "uds_path", uds_path);
692b48
+
692b48
+        /* Remove the UDS path from *url and r->filename */
692b48
+        url_len = strlen(origin_url);
692b48
+        *url = apr_pstrmemdup(r->pool, origin_url, url_len);
692b48
+        memcpy(uds_url, *url, url_len + 1);
692b48
+
692b48
+        ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, r,
692b48
+                 "*: rewrite of url due to UDS(%s): %s (%s)",
692b48
+                 uds_path, *url, r->filename);
692b48
+     }
692b48
+
692b48
+     return 1;
692b48
 }
692b48
 
692b48
 PROXY_DECLARE(int) ap_proxy_pre_request(proxy_worker **worker,
692b48
@@ -2128,7 +2140,9 @@ PROXY_DECLARE(int) ap_proxy_pre_request(proxy_worker **worker,
692b48
                           "%s: found worker %s for %s",
692b48
                           (*worker)->s->scheme, (*worker)->s->name, *url);
692b48
             *balancer = NULL;
692b48
-            fix_uds_filename(r, url);
692b48
+            if (!fix_uds_filename(r, url)) {
692b48
+                     return HTTP_INTERNAL_SERVER_ERROR;
692b48
+            }
692b48
             access_status = OK;
692b48
         }
692b48
         else if (r->proxyreq == PROXYREQ_PROXY) {
692b48
@@ -2159,7 +2173,9 @@ PROXY_DECLARE(int) ap_proxy_pre_request(proxy_worker **worker,
692b48
                  * regarding the Connection header in the request.
692b48
                  */
692b48
                 apr_table_setn(r->subprocess_env, "proxy-nokeepalive", "1");
692b48
-                fix_uds_filename(r, url);
692b48
+                if (!fix_uds_filename(r, url)) {
692b48
+                     return HTTP_INTERNAL_SERVER_ERROR;
692b48
+                }
692b48
             }
692b48
         }
692b48
     }