From 5fa8930468f5ec5d64ce160e40caf7f779ce617d Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Tue, 30 Jul 2002 22:27:21 +0000 Subject: some snprintf and strlcpy --- libexec/tcpd/tcpdchk/inetcf.c | 8 ++++---- libexec/tcpd/tcpdchk/scaffold.c | 6 +++--- libexec/tcpd/tcpdchk/tcpdchk.c | 10 +++++----- 3 files changed, 12 insertions(+), 12 deletions(-) (limited to 'libexec/tcpd/tcpdchk') diff --git a/libexec/tcpd/tcpdchk/inetcf.c b/libexec/tcpd/tcpdchk/inetcf.c index c2ebf5307ea..370a6650668 100644 --- a/libexec/tcpd/tcpdchk/inetcf.c +++ b/libexec/tcpd/tcpdchk/inetcf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: inetcf.c,v 1.1 1997/02/26 06:17:07 downsj Exp $ */ +/* $OpenBSD: inetcf.c,v 1.2 2002/07/30 22:27:20 deraadt Exp $ */ /* * Routines to parse an inetd.conf or tlid.conf file. This would be a great @@ -11,7 +11,7 @@ #if 0 static char sccsid[] = "@(#) inetcf.c 1.7 97/02/12 02:13:23"; #else -static char rcsid[] = "$OpenBSD: inetcf.c,v 1.1 1997/02/26 06:17:07 downsj Exp $"; +static char rcsid[] = "$OpenBSD: inetcf.c,v 1.2 2002/07/30 22:27:20 deraadt Exp $"; #endif #endif @@ -235,7 +235,7 @@ char *arg1; tcpd_warn("%s: not executable", arg0); } } else { /* look in REAL_DAEMON_DIR */ - sprintf(daemon, "%s/%s", REAL_DAEMON_DIR, arg0); + snprintf(daemon, sizeof daemon, "%s/%s", REAL_DAEMON_DIR, arg0); if (check_path(daemon, &st) < 0) { tcpd_warn("%s: not found in %s: %m", arg0, REAL_DAEMON_DIR); @@ -251,7 +251,7 @@ char *arg1; * recipe. Look for a file with the same basename in REAL_DAEMON_DIR. * Draw some conservative conclusions when a distinct file is found. */ - sprintf(daemon, "%s/%s", REAL_DAEMON_DIR, arg0); + snprintf(daemon, sizeof daemon, "%s/%s", REAL_DAEMON_DIR, arg0); if (STR_EQ(path, daemon)) { wrap_status = WR_NOT; } else if (check_path(daemon, &st) >= 0) { diff --git a/libexec/tcpd/tcpdchk/scaffold.c b/libexec/tcpd/tcpdchk/scaffold.c index 582cea1d173..da0467d383b 100644 --- a/libexec/tcpd/tcpdchk/scaffold.c +++ b/libexec/tcpd/tcpdchk/scaffold.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scaffold.c,v 1.6 2002/06/07 03:32:04 itojun Exp $ */ +/* $OpenBSD: scaffold.c,v 1.7 2002/07/30 22:27:20 deraadt Exp $ */ /* * Routines for testing only. Not really industrial strength. @@ -10,7 +10,7 @@ #if 0 static char sccs_id[] = "@(#) scaffold.c 1.5 95/01/03 09:13:48"; #else -static char rcsid[] = "$OpenBSD: scaffold.c,v 1.6 2002/06/07 03:32:04 itojun Exp $"; +static char rcsid[] = "$OpenBSD: scaffold.c,v 1.7 2002/07/30 22:27:20 deraadt Exp $"; #endif #endif @@ -159,7 +159,7 @@ struct stat *st; if (st->st_mode & 002) tcpd_warn("%s: world writable", path); if (path[0] == '/' && path[1] != 0) { - strrchr(strcpy(buf, path), '/')[0] = 0; + strrchr((strlcpy(buf, path, sizeof buf), buf), '/')[0] = 0; (void) check_path(buf[0] ? buf : "/", &stbuf); } return (0); diff --git a/libexec/tcpd/tcpdchk/tcpdchk.c b/libexec/tcpd/tcpdchk/tcpdchk.c index ebe74dafcc7..3e3353d2ba4 100644 --- a/libexec/tcpd/tcpdchk/tcpdchk.c +++ b/libexec/tcpd/tcpdchk/tcpdchk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcpdchk.c,v 1.6 2002/06/07 03:32:04 itojun Exp $ */ +/* $OpenBSD: tcpdchk.c,v 1.7 2002/07/30 22:27:20 deraadt Exp $ */ /* * tcpdchk - examine all tcpd access control rules and inetd.conf entries @@ -20,7 +20,7 @@ #if 0 static char sccsid[] = "@(#) tcpdchk.c 1.8 97/02/12 02:13:25"; #else -static char rcsid[] = "$OpenBSD: tcpdchk.c,v 1.6 2002/06/07 03:32:04 itojun Exp $"; +static char rcsid[] = "$OpenBSD: tcpdchk.c,v 1.7 2002/07/30 22:27:20 deraadt Exp $"; #endif #endif @@ -287,7 +287,7 @@ char *list; char *next; fputs(title, stdout); - strcpy(buf, list); + strlcpy(buf, list, sizeof buf); for (cp = strtok(buf, sep); cp != 0; cp = next) { fputs(cp, stdout); @@ -308,7 +308,7 @@ char *list; char *host; int daemons = 0; - strcpy(buf, list); + strlcpy(buf, list, sizeof buf); for (cp = strtok(buf, sep); cp != 0; cp = strtok((char *) 0, sep)) { if (STR_EQ(cp, "EXCEPT")) { @@ -339,7 +339,7 @@ char *list; int l; #endif - strcpy(buf, list); + strlcpy(buf, list, sizeof buf); for (cp = strtok(buf, sep); cp != 0; cp = strtok((char *) 0, sep)) { #ifdef INET6 -- cgit v1.2.3