Web lists-archives.com

[PATCH v3 2/2] http: fix the silent ignoring of proxy misconfiguraion

Earlier, the whole http.proxy option string was passed to curl without
any preprocessing so curl could complain about the invalid proxy

After the commit 372370f167 ("http: use credential API to handle proxy
authentication", 2016-01-26), if the user specified an invalid HTTP
proxy option in the configuration, then the option parsing is silently
fails and NULL will be passed to curl as a proxy. This forces curl to
fall back to detecting the proxy configuration from the environment,
causing the http.proxy option ignoring.

Fix this issue by checking the proxy option parsing result. If parsing
failed then print error message and die. Such behaviour allows user to
quickly figure the proxy misconfiguration and correct it.

Helped-by: Jeff King <peff@xxxxxxxx>
Signed-off-by: Sergey Ryazanov <ryazanov.s.a@xxxxxxxxx>

Changes since v2:
  - new patch

 http.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/http.c b/http.c
index 8be75b2..82664dd 100644
--- a/http.c
+++ b/http.c
@@ -867,6 +867,9 @@ static CURL *get_curl_handle(void)
+		if (!proxy_auth.host)
+			die("Invalid proxy URL '%s'", curl_http_proxy);
 		curl_easy_setopt(result, CURLOPT_PROXY, proxy_auth.host);
 #if LIBCURL_VERSION_NUM >= 0x071304
 		var_override(&curl_no_proxy, getenv("NO_PROXY"));