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