summaryrefslogtreecommitdiffstats
path: root/libexec/talkd
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/talkd
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/talkd')
-rw-r--r--libexec/talkd/talkd.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/libexec/talkd/talkd.c b/libexec/talkd/talkd.c
index bb61f7e..72e4a5f 100644
--- a/libexec/talkd/talkd.c
+++ b/libexec/talkd/talkd.c
@@ -42,7 +42,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)talkd.c 8.1 (Berkeley) 6/4/93";
#endif
static const char rcsid[] =
- "$Id: talkd.c,v 1.8 1997/12/02 12:33:42 charnier Exp $";
+ "$Id: talkd.c,v 1.9 1998/12/01 21:12:57 dillon Exp $";
#endif /* not lint */
/*
@@ -73,7 +73,7 @@ int sockt;
int debug = 0;
long lastmsgtime;
-char hostname[MAXHOSTNAMELEN + 1];
+char hostname[MAXHOSTNAMELEN];
#define TIMEOUT 30
#define MAXIDLE 120
@@ -97,10 +97,11 @@ main(argc, argv)
errx(1, "getuid: not super-user");
#endif
openlog("talkd", LOG_PID, LOG_DAEMON);
- if (gethostname(hostname, sizeof (hostname) - 1) < 0) {
+ if (gethostname(hostname, sizeof(hostname) - 1) < 0) {
syslog(LOG_ERR, "gethostname: %m");
_exit(1);
}
+ hostname[sizeof(hostname) - 1] = '\0';
if (chdir(_PATH_DEV) < 0) {
syslog(LOG_ERR, "chdir: %s: %m", _PATH_DEV);
_exit(1);
OpenPOWER on IntegriCloud