cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: [PATCH] Support socks proxy specification in "all_proxy" variable

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Wed, 27 Apr 2011 15:15:06 -0700

On Wed, Apr 27, 2011 at 11:34:11PM +0200, Daniel Stenberg wrote:
> free(proxy); /* Don't bother with an empty proxy string */
> proxy = NULL;
> }
> +
> + /***********************************************************************
> + * If this is supposed to use a proxy, we need to figure out the proxy host
> + * name, proxy type and port number, so that we can re-use an existing
> + * connection that may exist registered to the same proxy host.
> + ***********************************************************************/
> + if(proxy) {
> + result = parse_proxy(data, conn, proxy);
> + /* parse_proxy has freed the proxy string, so don't try to use it again */

This part doesn't look right. The original code (below) had a proxy=NULL line
here because proxy has been freed by this point. This comment no longer makes
sense without that.

> + if(result != CURLE_OK)
> + return result;
> + }
> +
> /* proxy must be freed later unless NULL */
> if(proxy && !(conn->handler->flags & PROTOPT_BANPROXY)) {
> if((conn->proxytype == CURLPROXY_HTTP) ||

And since proxy has been freed, the second last line above references either
freed memory (which is plainly wrong), or if proxy=NULL is reinstated above,
this block of code will never be executed (which is less obviously wrong).

> @@ -4790,18 +4807,6 @@ static CURLcode create_conn(struct SessionHandle *data,
> conn->bits.tunnel_proxy = FALSE;
> }
>
> - /***********************************************************************
> - * If this is supposed to use a proxy, we need to figure out the proxy
> - * host name, so that we can re-use an existing connection
> - * that may exist registered to the same proxy host.
> - ***********************************************************************/
> - if(proxy) {
> - result = parse_proxy(data, conn, proxy);
> - /* parse_proxy has freed the proxy string, so don't try to use it again */
> - proxy = NULL;
> - if(result != CURLE_OK)
> - return result;
> - }
> #endif /* CURL_DISABLE_PROXY */

>>> Dan
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-04-28