Skip to content

Commit 2459dc7

Browse files
committed
http: the :authority header should never contain user+password
Pointed-out-by: Stanislav Fort Closes curl#19568
1 parent 4075339 commit 2459dc7

1 file changed

Lines changed: 2 additions & 25 deletions

File tree

lib/http.c

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4558,12 +4558,12 @@ CURLcode Curl_http_req_make(struct httpreq **preq,
45584558

45594559
static CURLcode req_assign_url_authority(struct httpreq *req, CURLU *url)
45604560
{
4561-
char *user, *pass, *host, *port;
4561+
char *host, *port;
45624562
struct dynbuf buf;
45634563
CURLUcode uc;
45644564
CURLcode result = CURLE_URL_MALFORMAT;
45654565

4566-
user = pass = host = port = NULL;
4566+
host = port = NULL;
45674567
curlx_dyn_init(&buf, DYN_HTTP_REQUEST);
45684568

45694569
uc = curl_url_get(url, CURLUPART_HOST, &host, 0);
@@ -4578,28 +4578,7 @@ static CURLcode req_assign_url_authority(struct httpreq *req, CURLU *url)
45784578
uc = curl_url_get(url, CURLUPART_PORT, &port, CURLU_NO_DEFAULT_PORT);
45794579
if(uc && uc != CURLUE_NO_PORT)
45804580
goto out;
4581-
uc = curl_url_get(url, CURLUPART_USER, &user, 0);
4582-
if(uc && uc != CURLUE_NO_USER)
4583-
goto out;
4584-
if(user) {
4585-
uc = curl_url_get(url, CURLUPART_PASSWORD, &pass, 0);
4586-
if(uc && uc != CURLUE_NO_PASSWORD)
4587-
goto out;
4588-
}
45894581

4590-
if(user) {
4591-
result = curlx_dyn_add(&buf, user);
4592-
if(result)
4593-
goto out;
4594-
if(pass) {
4595-
result = curlx_dyn_addf(&buf, ":%s", pass);
4596-
if(result)
4597-
goto out;
4598-
}
4599-
result = curlx_dyn_add(&buf, "@");
4600-
if(result)
4601-
goto out;
4602-
}
46034582
result = curlx_dyn_add(&buf, host);
46044583
if(result)
46054584
goto out;
@@ -4614,8 +4593,6 @@ static CURLcode req_assign_url_authority(struct httpreq *req, CURLU *url)
46144593
result = CURLE_OK;
46154594

46164595
out:
4617-
free(user);
4618-
free(pass);
46194596
free(host);
46204597
free(port);
46214598
curlx_dyn_free(&buf);

0 commit comments

Comments
 (0)