netrc: 'default' with no credentials is not a match

Test 486 verifies.

Reported-by: Yihang Zhou

Closes #15908
This commit is contained in:
Daniel Stenberg 2025-01-03 16:22:27 +01:00
parent abf8062449
commit 0e120c5b92
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
3 changed files with 116 additions and 6 deletions

View file

@ -316,11 +316,16 @@ static int parsenetrc(struct store_netrc *store,
out:
Curl_dyn_free(&token);
if(!retcode && !password && our_login) {
/* success without a password, set a blank one */
password = strdup("");
if(!password)
retcode = 1; /* out of memory */
if(!retcode) {
if(!password && our_login) {
/* success without a password, set a blank one */
password = strdup("");
if(!password)
retcode = 1; /* out of memory */
}
else if(!login && !password)
/* a default with no credentials */
retcode = NETRC_FILE_MISSING;
}
if(!retcode) {
/* success */