From 8bd03516d62ab08972190e2ccdaa06ab1d692125 Mon Sep 17 00:00:00 2001 From: Jay Satiro Date: Wed, 29 Jun 2022 03:43:56 -0400 Subject: [PATCH] url: treat missing usernames in netrc as empty MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit - 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 --- lib/url.c | 6 ++++++ 1 file changed, 6 insertions(+) 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 -- 2.47.3