On Fri, Apr 18, 2014 at 5:57 PM, Yann Ylavic <ylavic....@gmail.com> wrote:
> Patch inline.
>
> Index: modules/proxy/proxy_util.c
> ===================================================================
> --- modules/proxy/proxy_util.c    (revision 1588466)
> +++ modules/proxy/proxy_util.c    (working copy)
> @@ -1508,32 +1508,111 @@ PROXY_DECLARE(char *) ap_proxy_worker_name(apr_poo
[...]
> +PROXY_DECLARE(proxy_worker *) ap_proxy_get_worker_ex(apr_pool_t *p,
> +                                                     proxy_balancer 
> *balancer,
> +                                                     proxy_server_conf *conf,
> +                                                     const char *url, int 
> uds,
> +                                                     char **to, char **by)
> +{
[...]
> +    if (!uds) {
> +        /* No real interest in *to or *by being used without uds,
> +         * don't leave dangling pointers anyway.
> +         */
> +        if (to) {
> +            *to = NULL;
> +        }
> +        if (by) {
> +            *by = NULL;
> +        }
> +        url_length = 0;
> +        url_copy = NULL;
> +    }
> +    else {
> +        url_length = strlen(url);

Not the right place to initialize url_length, will be fixed in next
patch (if useful).

> +        url_copy = apr_pstrmemdup(p, url, url_length);
> +        url_copy = ap_proxy_split_url(p, url_copy, by);
> +        if (to) {
> +            *to = url_copy;
> +        }
> +        url = url_copy;
> +    }
> +
>      c = ap_strchr_c(url, ':');
>      if (c == NULL || c[1] != '/' || c[2] != '/' || c[3] == '\0') {
>          return NULL;
>      }
>
> -    url_length = strlen(url);
> -    url_copy = apr_pstrmemdup(p, url, url_length);
> +    if (!url_copy) {
> +        url_length = strlen(url);
> +        url_copy = apr_pstrmemdup(p, url, url_length);
> +    }
>

Please read something the following instead :

+    if (!uds) {
+        /* No real interest in *to or *by being used without uds,
+         * don't leave dangling pointers anyway.
+         */
+        if (to) {
+            *to = NULL;
+        }
+        if (by) {
+            *by = NULL;
+        }
+        url_copy = NULL;
+    }
+    else {
+        url_copy = ap_proxy_split_url(p, apr_pstrdup(p, url), by);
+        if (to) {
+            *to = url_copy;
+        }
+        url = url_copy;
+    }
+
     c = ap_strchr_c(url, ':');
     if (c == NULL || c[1] != '/' || c[2] != '/' || c[3] == '\0') {
         return NULL;
     }

     url_length = strlen(url);
-    url_copy = apr_pstrmemdup(p, url, url_length);
+    if (url_copy == NULL) {
+        url_copy = apr_pstrmemdup(p, url, url_length);
+    }

Reply via email to