http: fix Basic auth with empty name field in URL

Add test 367 to verify.

Reported-by: Rick Lane
Fixes #7819
Closes #7820
This commit is contained in:
Daniel Stenberg 2021-10-06 15:40:53 +02:00
parent 5f563495f1
commit 87907d56f0
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
3 changed files with 50 additions and 2 deletions

View file

@ -323,7 +323,7 @@ static CURLcode http_output_basic(struct Curl_easy *data, bool proxy)
pwd = data->state.aptr.passwd;
}
out = aprintf("%s:%s", user, pwd ? pwd : "");
out = aprintf("%s:%s", user ? user : "", pwd ? pwd : "");
if(!out)
return CURLE_OUT_OF_MEMORY;