diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-08-27 10:23:01 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-08-27 10:23:01 +0000 |
commit | 0f7e2904e911f96612afeafde7819fa1e4dc54cf (patch) | |
tree | 6f998798a07036e99b85f22f624d4d3921532fdc | |
parent | b599ca4ee02d7ee92a38332bd0bce529fdbf6bf8 (diff) |
strncpy correctly
-rw-r--r-- | libexec/comsat/comsat.c | 4 | ||||
-rw-r--r-- | libexec/uucpd/uucpd.c | 7 |
2 files changed, 6 insertions, 5 deletions
diff --git a/libexec/comsat/comsat.c b/libexec/comsat/comsat.c index b0eaec4fece..0b4e41d3273 100644 --- a/libexec/comsat/comsat.c +++ b/libexec/comsat/comsat.c @@ -39,7 +39,7 @@ static char copyright[] = #ifndef lint /*static char sccsid[] = "from: @(#)comsat.c 8.1 (Berkeley) 6/4/93";*/ -static char rcsid[] = "$Id: comsat.c,v 1.1 1995/10/18 08:43:15 deraadt Exp $"; +static char rcsid[] = "$Id: comsat.c,v 1.2 1996/08/27 10:22:04 deraadt Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -221,7 +221,7 @@ notify(utp, offset) (void)tcgetattr(fileno(tp), &ttybuf); cr = (ttybuf.c_oflag & ONLCR) && (ttybuf.c_oflag & OPOST) ? "\n" : "\n\r"; - (void)strncpy(name, utp->ut_name, sizeof(utp->ut_name)); + (void)strncpy(name, utp->ut_name, sizeof(name) - 1); name[sizeof(name) - 1] = '\0'; (void)fprintf(tp, "%s\007New mail for %s@%.*s\007 has arrived:%s----%s", cr, name, (int)sizeof(hostname), hostname, cr, cr); diff --git a/libexec/uucpd/uucpd.c b/libexec/uucpd/uucpd.c index 98d3c67e3c0..8e14b5177c1 100644 --- a/libexec/uucpd/uucpd.c +++ b/libexec/uucpd/uucpd.c @@ -42,7 +42,7 @@ char copyright[] = #ifndef lint /*static char sccsid[] = "from: @(#)uucpd.c 5.10 (Berkeley) 2/26/91";*/ -static char rcsid[] = "$Id: uucpd.c,v 1.2 1996/07/22 02:00:12 deraadt Exp $"; +static char rcsid[] = "$Id: uucpd.c,v 1.3 1996/08/27 10:23:00 deraadt Exp $"; #endif /* not lint */ /* @@ -263,11 +263,12 @@ struct sockaddr_in *sin; sizeof (struct in_addr), AF_INET); if (hp) { - strncpy(remotehost, hp->h_name, sizeof (remotehost)); + strncpy(remotehost, hp->h_name, sizeof(remotehost)-1); endhostent(); } else strncpy(remotehost, inet_ntoa(sin->sin_addr), - sizeof (remotehost)); + sizeof(remotehost)-1); + remotehost[sizeof(remotehost)-1] = '\0'; wtmp = open(_PATH_WTMP, O_WRONLY|O_APPEND); if (wtmp >= 0) { /* hack, but must be unique and no tty line */ |