libfetch: do not give out user/hostname as ftp anonymous password
This is unwanted information disclosure. Reported-by: Max Justicz <max@justi.cz>cute-signatures
parent
7b654e1254
commit
e4f54cfe66
|
@ -79,6 +79,7 @@
|
||||||
|
|
||||||
static int ftp_cmd(conn_t *, const char *, ...) LIBFETCH_PRINTFLIKE(2, 3);
|
static int ftp_cmd(conn_t *, const char *, ...) LIBFETCH_PRINTFLIKE(2, 3);
|
||||||
#define FTP_ANONYMOUS_USER "anonymous"
|
#define FTP_ANONYMOUS_USER "anonymous"
|
||||||
|
#define FTP_ANONYMOUS_PASSWORD "anonymous"
|
||||||
|
|
||||||
#define FTP_CONNECTION_ALREADY_OPEN 125
|
#define FTP_CONNECTION_ALREADY_OPEN 125
|
||||||
#define FTP_OPEN_DATA_CONNECTION 150
|
#define FTP_OPEN_DATA_CONNECTION 150
|
||||||
|
@ -959,9 +960,8 @@ ouch:
|
||||||
static int
|
static int
|
||||||
ftp_authenticate(conn_t *conn, struct url *url, struct url *purl)
|
ftp_authenticate(conn_t *conn, struct url *url, struct url *purl)
|
||||||
{
|
{
|
||||||
const char *user, *pwd, *login_name;
|
const char *user, *pwd;
|
||||||
char pbuf[URL_USERLEN + 1 + URL_HOSTLEN + 1];
|
int e;
|
||||||
int e, len;
|
|
||||||
|
|
||||||
/* XXX FTP_AUTH, and maybe .netrc */
|
/* XXX FTP_AUTH, and maybe .netrc */
|
||||||
|
|
||||||
|
@ -985,18 +985,8 @@ ftp_authenticate(conn_t *conn, struct url *url, struct url *purl)
|
||||||
pwd = url->pwd;
|
pwd = url->pwd;
|
||||||
if (*pwd == '\0')
|
if (*pwd == '\0')
|
||||||
pwd = getenv("FTP_PASSWORD");
|
pwd = getenv("FTP_PASSWORD");
|
||||||
if (pwd == NULL || *pwd == '\0') {
|
if (pwd == NULL || *pwd == '\0')
|
||||||
if ((login_name = getlogin()) == 0)
|
pwd = FTP_ANONYMOUS_PASSWORD;
|
||||||
login_name = FTP_ANONYMOUS_USER;
|
|
||||||
if ((len = snprintf(pbuf, URL_USERLEN + 2, "%s@", login_name)) < 0)
|
|
||||||
len = 0;
|
|
||||||
else if (len > URL_USERLEN + 1)
|
|
||||||
len = URL_USERLEN + 1;
|
|
||||||
gethostname(pbuf + len, sizeof(pbuf) - len);
|
|
||||||
/* MAXHOSTNAMELEN can differ from URL_HOSTLEN + 1 */
|
|
||||||
pbuf[sizeof(pbuf) - 1] = '\0';
|
|
||||||
pwd = pbuf;
|
|
||||||
}
|
|
||||||
e = ftp_cmd(conn, "PASS %s\r\n", pwd);
|
e = ftp_cmd(conn, "PASS %s\r\n", pwd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue