diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-08-27 10:27:00 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-08-27 10:27:00 +0000 |
commit | d21d48db18c4d62ff0fd6630fcb728ff04939183 (patch) | |
tree | 9f2c9ee0c7584d9e416fe4a8ed64d0fa2f3d96c7 | |
parent | 3c9fe3b70bb90c5ae8602e74372825e99ab24805 (diff) |
strncpy correctly
-rw-r--r-- | libexec/rlogind/rlogind.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/libexec/rlogind/rlogind.c b/libexec/rlogind/rlogind.c index cf016a9397e..8e5ba9348c5 100644 --- a/libexec/rlogind/rlogind.c +++ b/libexec/rlogind/rlogind.c @@ -39,7 +39,7 @@ static char copyright[] = #ifndef lint /* from: static char sccsid[] = "@(#)rlogind.c 8.1 (Berkeley) 6/4/93"; */ -static char *rcsid = "$Id: rlogind.c,v 1.8 1996/08/02 10:13:35 deraadt Exp $"; +static char *rcsid = "$Id: rlogind.c,v 1.9 1996/08/27 10:26:59 deraadt Exp $"; #endif /* not lint */ /* @@ -216,7 +216,7 @@ doit(f, fromp) hp = gethostbyaddr((char *)&fromp->sin_addr, sizeof(struct in_addr), fromp->sin_family); if (hp) { - strncpy(hostname, hp->h_name, sizeof hostname); + strncpy(hostname, hp->h_name, sizeof(hostname)-1); if (check_all) { hp = gethostbyname(hostname); if (hp) { @@ -233,7 +233,8 @@ doit(f, fromp) } /* aha, the DNS looks spoofed */ if (hp == NULL || good == 0) - strncpy(hostname, inet_ntoa(fromp->sin_addr), sizeof hostname); + strncpy(hostname, inet_ntoa(fromp->sin_addr), sizeof(hostname)-1); + hostname[sizeof(hostname)-1] = '\0'; #ifdef KERBEROS |