From: Jay Satiro Date: Wed, 29 Jun 2022 07:43:56 +0000 (-0400) Subject: url: treat missing usernames in netrc as empty X-Git-Tag: curl-7_85_0~9 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8bd03516d62ab08972190e2ccdaa06ab1d692125;p=thirdparty%2Fcurl.git 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 Testing-by: Domen Kožar Fixes https://github.com/curl/curl/issues/8653 Closes #9334 Closes #9066 --- diff --git a/lib/url.c b/lib/url.c index 54e4d04e53..33c6a2135a 100644 --- a/lib/url.c +++ b/lib/url.c @@ -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