From 1a01a6b2d0a572b316fa8683614feb5ad723b38d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20R=C3=BChsen?= Date: Sat, 7 Jan 2017 15:59:11 +0100 Subject: [PATCH] Fix previous commit 2427ca4ac090dc6cc0c527f4ac4fc5a4bd468eb1 --- src/ftp.c | 5 ++++- src/http.c | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/ftp.c b/src/ftp.c index d9dc623b..1e5f3420 100644 --- a/src/ftp.c +++ b/src/ftp.c @@ -370,6 +370,7 @@ getftp (struct url *u, struct url *original_url, user = opt.user; else user = NULL; + /* Find the password with priority */ if (u->passwd) passwd = u->passwd; @@ -381,9 +382,11 @@ getftp (struct url *u, struct url *original_url, passwd = opt.passwd; else passwd = NULL; + /* Check for ~/.netrc if none of the above match */ if (opt.netrc && (!user || !passwd)) - search_netrc (u->host, (const char **)&user, (const char **)&passwd, 1); + search_netrc (u->host, (const char **) &user, (const char **) &passwd, 1); + if (!user) user = "anonymous"; if (!passwd) passwd = "-wget@"; diff --git a/src/http.c b/src/http.c index 7ef88eb0..ddfaefa3 100644 --- a/src/http.c +++ b/src/http.c @@ -1886,6 +1886,7 @@ initialize_request (const struct url *u, struct http_stat *hs, int *dt, struct u *user = opt.user; else *user = NULL; + /* Find the password with priority */ if (u->passwd) *passwd = u->passwd; @@ -1897,9 +1898,10 @@ initialize_request (const struct url *u, struct http_stat *hs, int *dt, struct u *passwd = opt.passwd; else *passwd = NULL; + /* Check for ~/.netrc if none of the above match */ - if (opt.netrc && (!(*user) || !(*password))) - search_netrc (u->host, (const char **)user, (const char **)passwd, 0); + if (opt.netrc && (!user || !passwd)) + search_netrc (u->host, (const char **) user, (const char **) passwd, 0); /* We only do "site-wide" authentication with "global" user/password * values unless --auth-no-challange has been requested; URL user/password