From: William Lallemand Date: Thu, 17 Oct 2024 09:57:29 +0000 (+0200) Subject: BUG/MINOR: httpclient: return NULL when no proxy available during httpclient_new() X-Git-Tag: v3.1-dev11~125 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e7b7072943d658702eba3651d66c6093f1a79fa8;p=thirdparty%2Fhaproxy.git BUG/MINOR: httpclient: return NULL when no proxy available during httpclient_new() Latest patches on the mworker rework skipped the httpclient_proxy creation by accident. This is not supposed to happen because haproxy is supposed to stop when the proxy creation failed, but it shows a flaw in the API. When the httpclient_proxy or the proxy used in parameter of httpclient_new_from_proxy() is NULL, it will be dereferenced and cause a crash. The patch only returns a NULL when doing an httpclient_new() if the proxy is not available. Must be backported as far as 2.7. --- diff --git a/src/http_client.c b/src/http_client.c index ff2ab4e85f..f137a6e3be 100644 --- a/src/http_client.c +++ b/src/http_client.c @@ -628,6 +628,9 @@ struct httpclient *httpclient_new(void *caller, enum http_meth_t meth, struct is { struct httpclient *hc; + if (!httpclient_proxy) + return NULL; + hc = calloc(1, sizeof(*hc)); if (!hc) goto err; @@ -655,6 +658,9 @@ struct httpclient *httpclient_new_from_proxy(struct proxy *px, void *caller, enu { struct httpclient *hc; + if (!px) + return NULL; + hc = httpclient_new(caller, meth, url); if (!hc) return NULL;