summaryrefslogtreecommitdiffstats
path: root/Utilities/cmcurl/lib/netrc.c
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-09-15 19:28:38 (GMT)
committerBrad King <brad.king@kitware.com>2021-09-15 19:28:38 (GMT)
commit8ecd95845cf0254259cd19a0550beafe83131708 (patch)
tree6983d7d95f0c7be15b33cf7953c3a9ebc9f815b8 /Utilities/cmcurl/lib/netrc.c
parenta8ae9c7055fc5d7175a3082640733745248b4274 (diff)
parent386467c9dc939cd20711c451dd7d60341fd0e802 (diff)
downloadCMake-8ecd95845cf0254259cd19a0550beafe83131708.zip
CMake-8ecd95845cf0254259cd19a0550beafe83131708.tar.gz
CMake-8ecd95845cf0254259cd19a0550beafe83131708.tar.bz2
Merge branch 'upstream-curl' into update-curl
* upstream-curl: curl 2021-09-14 (8e82f2a0)
Diffstat (limited to 'Utilities/cmcurl/lib/netrc.c')
-rw-r--r--Utilities/cmcurl/lib/netrc.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/Utilities/cmcurl/lib/netrc.c b/Utilities/cmcurl/lib/netrc.c
index 13610bb..0a4ae2c 100644
--- a/Utilities/cmcurl/lib/netrc.c
+++ b/Utilities/cmcurl/lib/netrc.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -42,7 +42,8 @@
enum host_lookup_state {
NOTHING,
HOSTFOUND, /* the 'machine' keyword was found */
- HOSTVALID /* this is "our" machine! */
+ HOSTVALID, /* this is "our" machine! */
+ MACDEF
};
#define NETRC_FILE_MISSING 1
@@ -84,12 +85,17 @@ static int parsenetrc(const char *host,
int netrcbuffsize = (int)sizeof(netrcbuffer);
while(!done && fgets(netrcbuffer, netrcbuffsize, file)) {
+ if(state == MACDEF) {
+ if((netrcbuffer[0] == '\n') || (netrcbuffer[0] == '\r'))
+ state = NOTHING;
+ else
+ continue;
+ }
tok = strtok_r(netrcbuffer, " \t\n", &tok_buf);
if(tok && *tok == '#')
/* treat an initial hash as a comment line */
continue;
while(tok) {
-
if((login && *login) && (password && *password)) {
done = TRUE;
break;
@@ -97,7 +103,13 @@ static int parsenetrc(const char *host,
switch(state) {
case NOTHING:
- if(strcasecompare("machine", tok)) {
+ if(strcasecompare("macdef", tok)) {
+ /* Define a macro. A macro is defined with the specified name; its
+ contents begin with the next .netrc line and continue until a
+ null line (consecutive new-line characters) is encountered. */
+ state = MACDEF;
+ }
+ else if(strcasecompare("machine", tok)) {
/* the next tok is the machine name, this is in itself the
delimiter that starts the stuff entered for this machine,
after this we need to search for 'login' and
@@ -109,6 +121,11 @@ static int parsenetrc(const char *host,
retcode = NETRC_SUCCESS; /* we did find our host */
}
break;
+ case MACDEF:
+ if(!strlen(tok)) {
+ state = NOTHING;
+ }
+ break;
case HOSTFOUND:
if(strcasecompare(host, tok)) {
/* and yes, this is our host! */