summaryrefslogtreecommitdiffstats
path: root/libexec/rshd/rshd.c
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/rshd/rshd.c
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/rshd/rshd.c')
-rw-r--r--libexec/rshd/rshd.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/libexec/rshd/rshd.c b/libexec/rshd/rshd.c
index 5ed7437b..24b7d35 100644
--- a/libexec/rshd/rshd.c
+++ b/libexec/rshd/rshd.c
@@ -42,7 +42,7 @@ static const char copyright[] =
static const char sccsid[] = "@(#)rshd.c 8.2 (Berkeley) 4/6/94";
#endif
static const char rcsid[] =
- "$Id: rshd.c,v 1.23 1998/12/16 07:20:45 peter Exp $";
+ "$Id: rshd.c,v 1.24 1999/04/06 23:05:58 brian Exp $";
#endif /* not lint */
/*
@@ -216,7 +216,7 @@ doit(fromp)
char *errorstr;
char *cp, sig, buf[BUFSIZ];
char cmdbuf[NCARGS+1], locuser[16], remuser[16];
- char fromhost[2 * MAXHOSTNAMELEN + 1];
+ char fromhost[MAXHOSTNAMELEN];
#ifdef LOGIN_CAP
login_cap_t *lc;
#endif
@@ -348,9 +348,7 @@ doit(fromp)
dup2(f, 2);
#endif
errorstr = NULL;
- strncpy(fromhost, inet_ntoa(fromp->sin_addr),
- sizeof(fromhost) - 1);
- realhostname(fromhost, sizeof fromhost - 1, &fromp->sin_addr);
+ realhostname(fromhost, sizeof(fromhost) - 1, &fromp->sin_addr);
fromhost[sizeof(fromhost) - 1] = '\0';
#ifdef KERBEROS
@@ -784,7 +782,8 @@ local_domain(h)
char *p1, *p2;
localhost[0] = 0;
- (void) gethostname(localhost, sizeof(localhost));
+ (void) gethostname(localhost, sizeof(localhost) - 1);
+ localhost[sizeof(localhost) - 1] = '\0';
p1 = topdomain(localhost);
p2 = topdomain(h);
if (p1 == NULL || p2 == NULL || !strcasecmp(p1, p2))
OpenPOWER on IntegriCloud