mirror of
https://github.com/moparisthebest/curl
synced 2024-08-13 17:03:50 -04:00
parse_proxy: fix a memory leak in the OOM path
Reported-by: Jay Satiro Reviewed-by: Jay Satiro Reviewed-by: Emil Engler Closes #6614 Bug: https://github.com/curl/curl/pull/6591#issuecomment-780396541
This commit is contained in:
parent
568190f493
commit
f248a13065
19
lib/url.c
19
lib/url.c
@ -2402,13 +2402,18 @@ static CURLcode parse_proxy(struct Curl_easy *data,
|
|||||||
proxyinfo->proxytype = proxytype;
|
proxyinfo->proxytype = proxytype;
|
||||||
|
|
||||||
/* Is there a username and password given in this proxy url? */
|
/* Is there a username and password given in this proxy url? */
|
||||||
curl_url_get(uhp, CURLUPART_USER, &proxyuser, CURLU_URLDECODE);
|
uc = curl_url_get(uhp, CURLUPART_USER, &proxyuser, CURLU_URLDECODE);
|
||||||
curl_url_get(uhp, CURLUPART_PASSWORD, &proxypasswd, CURLU_URLDECODE);
|
if(uc && (uc != CURLUE_NO_USER))
|
||||||
|
goto error;
|
||||||
|
uc = curl_url_get(uhp, CURLUPART_PASSWORD, &proxypasswd, CURLU_URLDECODE);
|
||||||
|
if(uc && (uc != CURLUE_NO_PASSWORD))
|
||||||
|
goto error;
|
||||||
|
|
||||||
if(proxyuser || proxypasswd) {
|
if(proxyuser || proxypasswd) {
|
||||||
Curl_safefree(proxyinfo->user);
|
Curl_safefree(proxyinfo->user);
|
||||||
proxyinfo->user = proxyuser;
|
proxyinfo->user = proxyuser;
|
||||||
result = Curl_setstropt(&data->state.aptr.proxyuser,
|
result = Curl_setstropt(&data->state.aptr.proxyuser, proxyuser);
|
||||||
proxyuser);
|
proxyuser = NULL;
|
||||||
if(result)
|
if(result)
|
||||||
goto error;
|
goto error;
|
||||||
Curl_safefree(proxyinfo->passwd);
|
Curl_safefree(proxyinfo->passwd);
|
||||||
@ -2420,8 +2425,8 @@ static CURLcode parse_proxy(struct Curl_easy *data,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
proxyinfo->passwd = proxypasswd;
|
proxyinfo->passwd = proxypasswd;
|
||||||
result = Curl_setstropt(&data->state.aptr.proxypasswd,
|
result = Curl_setstropt(&data->state.aptr.proxypasswd, proxypasswd);
|
||||||
proxypasswd);
|
proxypasswd = NULL;
|
||||||
if(result)
|
if(result)
|
||||||
goto error;
|
goto error;
|
||||||
conn->bits.proxy_user_passwd = TRUE; /* enable it */
|
conn->bits.proxy_user_passwd = TRUE; /* enable it */
|
||||||
@ -2469,6 +2474,8 @@ static CURLcode parse_proxy(struct Curl_easy *data,
|
|||||||
proxyinfo->host.name = host;
|
proxyinfo->host.name = host;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
|
free(proxyuser);
|
||||||
|
free(proxypasswd);
|
||||||
free(scheme);
|
free(scheme);
|
||||||
curl_url_cleanup(uhp);
|
curl_url_cleanup(uhp);
|
||||||
return result;
|
return result;
|
||||||
|
Loading…
Reference in New Issue
Block a user