mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-11-29 06:40:59 +01:00
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.
This commit is contained in:
parent
1fb61475f2
commit
e7b7072943
@ -628,6 +628,9 @@ struct httpclient *httpclient_new(void *caller, enum http_meth_t meth, struct is
|
|||||||
{
|
{
|
||||||
struct httpclient *hc;
|
struct httpclient *hc;
|
||||||
|
|
||||||
|
if (!httpclient_proxy)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
hc = calloc(1, sizeof(*hc));
|
hc = calloc(1, sizeof(*hc));
|
||||||
if (!hc)
|
if (!hc)
|
||||||
goto err;
|
goto err;
|
||||||
@ -655,6 +658,9 @@ struct httpclient *httpclient_new_from_proxy(struct proxy *px, void *caller, enu
|
|||||||
{
|
{
|
||||||
struct httpclient *hc;
|
struct httpclient *hc;
|
||||||
|
|
||||||
|
if (!px)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
hc = httpclient_new(caller, meth, url);
|
hc = httpclient_new(caller, meth, url);
|
||||||
if (!hc)
|
if (!hc)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user