diff options
author | Curl Upstream <curl-library@cool.haxx.se> | 2019-05-22 05:48:44 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-05-22 18:11:40 (GMT) |
commit | b26487c663ec29d972fd61adc2b14ac5880b78c7 (patch) | |
tree | 10220828b4a67af2a63ed9c6e8e4cb30160784ab /lib/netrc.c | |
parent | 9835e9075037db3d23ade0ef865c562b08cf6023 (diff) | |
download | CMake-b26487c663ec29d972fd61adc2b14ac5880b78c7.zip CMake-b26487c663ec29d972fd61adc2b14ac5880b78c7.tar.gz CMake-b26487c663ec29d972fd61adc2b14ac5880b78c7.tar.bz2 |
curl 2019-05-22 (885ce314)
Code extracted from:
https://github.com/curl/curl.git
at commit 885ce31401b6789c959131754b1e5ae518964072 (curl-7_65_0).
Diffstat (limited to 'lib/netrc.c')
-rw-r--r-- | lib/netrc.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/netrc.c b/lib/netrc.c index 1724b35..1bd998f 100644 --- a/lib/netrc.c +++ b/lib/netrc.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2019, 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 @@ -21,6 +21,7 @@ ***************************************************************************/ #include "curl_setup.h" +#ifndef CURL_DISABLE_NETRC #ifdef HAVE_PWD_H #include <pwd.h> @@ -53,6 +54,8 @@ enum host_lookup_state { int Curl_parsenetrc(const char *host, char **loginp, char **passwordp, + bool *login_changed, + bool *password_changed, char *netrcfile) { FILE *file; @@ -164,7 +167,7 @@ int Curl_parsenetrc(const char *host, if(specific_login) { state_our_login = strcasecompare(login, tok); } - else { + else if(!login || strcmp(login, tok)) { if(login_alloc) { free(login); login_alloc = FALSE; @@ -179,7 +182,8 @@ int Curl_parsenetrc(const char *host, state_login = 0; } else if(state_password) { - if(state_our_login || !specific_login) { + if((state_our_login || !specific_login) + && (!password || strcmp(password, tok))) { if(password_alloc) { free(password); password_alloc = FALSE; @@ -211,15 +215,19 @@ int Curl_parsenetrc(const char *host, out: if(!retcode) { + *login_changed = FALSE; + *password_changed = FALSE; if(login_alloc) { if(*loginp) free(*loginp); *loginp = login; + *login_changed = TRUE; } if(password_alloc) { if(*passwordp) free(*passwordp); *passwordp = password; + *password_changed = TRUE; } } else { @@ -233,3 +241,5 @@ int Curl_parsenetrc(const char *host, return retcode; } + +#endif |