summaryrefslogtreecommitdiffstats
path: root/libexec/ftpd
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>1999-04-07 08:27:45 +0000
committerbrian <brian@FreeBSD.org>1999-04-07 08:27:45 +0000
commitc6c6c7de65eae103002ebb9bee8881e1e2e903df (patch)
tree18fb09ba4ed57096b2a23fd9d28689784a00024b /libexec/ftpd
parent32ff8071a15df941cbe4d98c0badea284464f320 (diff)
downloadFreeBSD-src-c6c6c7de65eae103002ebb9bee8881e1e2e903df.zip
FreeBSD-src-c6c6c7de65eae103002ebb9bee8881e1e2e903df.tar.gz
Ensure that things returned by gethostname() and
friends are terminated and allow for a maximum host name length of MAXHOSTNAMELEN - 1. Put parenthesis around sizeof args. Make some variables static. Fix telnetd -u (broken by my last commit) Prompted by: bde
Diffstat (limited to 'libexec/ftpd')
-rw-r--r--libexec/ftpd/ftpd.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/libexec/ftpd/ftpd.c b/libexec/ftpd/ftpd.c
index 3012fab..aaa1e7d 100644
--- a/libexec/ftpd/ftpd.c
+++ b/libexec/ftpd/ftpd.c
@@ -44,7 +44,7 @@ static char copyright[] =
static char sccsid[] = "@(#)ftpd.c 8.4 (Berkeley) 4/16/94";
#endif
static const char rcsid[] =
- "$Id: ftpd.c,v 1.52 1998/10/13 20:42:01 des Exp $";
+ "$Id: ftpd.c,v 1.53 1999/04/06 23:05:57 brian Exp $";
#endif /* not lint */
/*
@@ -166,7 +166,7 @@ static struct ftphost {
} *thishost, *firsthost;
#endif
-char remotehost[MAXHOSTNAMELEN + 1];
+char remotehost[MAXHOSTNAMELEN];
char *ident = NULL;
static char ttyline[20];
@@ -542,7 +542,8 @@ main(argc, argv, envp)
#ifndef VIRTUAL_HOSTING
if ((hostname = malloc(MAXHOSTNAMELEN)) == NULL)
fatal("Ran out of memory.");
- (void) gethostname(hostname, MAXHOSTNAMELEN);
+ (void) gethostname(hostname, MAXHOSTNAMELEN - 1);
+ hostname[MAXHOSTNAMELEN - 1] = '\0';
#endif
reply(220, "%s FTP server (%s) ready.", hostname, version);
(void) setjmp(errcatch);
@@ -1896,7 +1897,7 @@ static void
dolog(sin)
struct sockaddr_in *sin;
{
- realhostname(remotehost, sizeof remotehost - 1, &sin->sin_addr);
+ realhostname(remotehost, sizeof(remotehost) - 1, &sin->sin_addr);
#ifdef SETPROCTITLE
#ifdef VIRTUAL_HOSTING
OpenPOWER on IntegriCloud