url: treat missing usernames in netrc as empty

- If, after parsing netrc, there is a password with no username then
  set a blank username.

This used to be the case prior to 7d600ad (precedes 7.82). Note
parseurlandfillconn already does the same thing for URLs.

Reported-by: Raivis <standsed@users.noreply.github.com>
Testing-by: Domen Kožar

Fixes https://github.com/curl/curl/issues/8653
Closes #9334
Closes #9066
This commit is contained in:
Jay Satiro 2022-06-29 03:43:56 -04:00 committed by Daniel Stenberg
parent 2fc031d834
commit 8bd03516d6
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2

View file

@ -3050,6 +3050,12 @@ static CURLcode override_login(struct Curl_easy *data,
/* don't update the user name below */
userp = NULL;
}
/* no user was set but a password, set a blank user */
if(userp && !*userp && *passwdp) {
*userp = strdup("");
if(!*userp)
return CURLE_OUT_OF_MEMORY;
}
}
#endif