On Thu, 21 May 2015, Daniel Stenberg wrote:

Right, and that's a combination we really should not allow. It is a bug. CURLOPT_HTTPPROXYTUNNEL implies a HTTP proxy, and socks5 means no HTTPTUNNEL...

... so I say we apply this patch so that setting either proxy type or proxytunnel make sure the other option is sensible.

You agree?

--

 / daniel.haxx.se
From c69b8aecb5e20572fd744a0f6888f26f3df60136 Mon Sep 17 00:00:00 2001
From: Daniel Stenberg <[email protected]>
Date: Thu, 21 May 2015 14:08:34 +0200
Subject: [PATCH] httpproxytunnel: implies HTTP proxy

CURLOPT_HTTPPROXYTUNNEL implies a HTTP proxy

A non-HTTP proxies implies not using CURLOPT_HTTPPROXYTUNNEL

Bug: http://curl.haxx.se/mail/lib-2015-05/0056.html
Reported-by: Sean Boudreau
---
 lib/url.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/lib/url.c b/lib/url.c
index 1b57ef1..9bbb681 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -1374,10 +1374,14 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
   case CURLOPT_HTTPPROXYTUNNEL:
     /*
      * Tunnel operations through the proxy instead of normal proxy use
      */
     data->set.tunnel_thru_httpproxy = (0 != va_arg(param, long))?TRUE:FALSE;
+    if(data->set.tunnel_thru_httpproxy &&
+       (data->set.proxytype > CURLPROXY_HTTP_1_0))
+      /* this option implies a HTTP proxy, change type if not already HTTP */
+      data->set.proxytype = CURLPROXY_HTTP;
     break;
 
   case CURLOPT_PROXYPORT:
     /*
      * Explicitly set HTTP proxy port number.
@@ -1452,10 +1456,13 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
   case CURLOPT_PROXYTYPE:
     /*
      * Set proxy type. HTTP/HTTP_1_0/SOCKS4/SOCKS4a/SOCKS5/SOCKS5_HOSTNAME
      */
     data->set.proxytype = (curl_proxytype)va_arg(param, long);
+    if(data->set.proxytype > CURLPROXY_HTTP_1_0)
+      /* non-HTTP proxy, make sure HTTP proxy tunneling is switched off */
+      data->set.tunnel_thru_httpproxy = FALSE;
     break;
 
   case CURLOPT_PROXY_TRANSFER_MODE:
     /*
      * set transfer mode (;type=<a|i>) when doing FTP via an HTTP proxy
-- 
2.1.4

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Reply via email to