]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
netrc: Use the password from lines without login
authorOrgad Shaneh <orgad.shaneh@audiocodes.com>
Thu, 4 Aug 2022 20:41:26 +0000 (23:41 +0300)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 29 Aug 2022 15:24:59 +0000 (17:24 +0200)
If netrc entry has password with empty login, use it for any username.

Example:
.netrc:
machine example.com password 123456

curl -vn http://user@example.com/

Fix it by initializing state_our_login to TRUE, and reset it only when
finding an entry with the same host and different login.

Closes #9248

lib/netrc.c

index 83fe6a7e09043576789c60f4f58d13951ec24c59..62a6a10df8edd19e2229d170451579ce47d382f9 100644 (file)
@@ -73,8 +73,8 @@ static int parsenetrc(const char *host,
 
   char state_login = 0;      /* Found a login keyword */
   char state_password = 0;   /* Found a password keyword */
-  int state_our_login = FALSE;  /* With specific_login, found *our* login
-                                   name */
+  int state_our_login = TRUE;  /* With specific_login, found *our* login
+                                  name (or login-less line) */
 
   DEBUGASSERT(netrcfile);