summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pppd
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2015-01-16 06:39:28 +0000
committerderaadt <deraadt@openbsd.org>2015-01-16 06:39:28 +0000
commitb9fc9a728fce9c4289b7e9a992665e28d5629a54 (patch)
tree72b2433e418dfa1aef5fcf8305617b97979a25d8 /usr.sbin/pppd
parentimprove checksum parsing slightly. now handles filenames with spaces. (diff)
downloadwireguard-openbsd-b9fc9a728fce9c4289b7e9a992665e28d5629a54.tar.xz
wireguard-openbsd-b9fc9a728fce9c4289b7e9a992665e28d5629a54.zip
Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where sensible to avoid pulling in the pollution. These are the files confirmed through binary verification. ok guenther, millert, doug (helped with the verification protocol)
Diffstat (limited to 'usr.sbin/pppd')
-rw-r--r--usr.sbin/pppd/auth.c5
-rw-r--r--usr.sbin/pppd/demand.c16
-rw-r--r--usr.sbin/pppd/ipcp.c9
-rw-r--r--usr.sbin/pppd/main.c28
-rw-r--r--usr.sbin/pppd/options.c8
-rw-r--r--usr.sbin/pppd/pppd.h7
-rw-r--r--usr.sbin/pppd/pppstats/pppstats.c15
7 files changed, 41 insertions, 47 deletions
diff --git a/usr.sbin/pppd/auth.c b/usr.sbin/pppd/auth.c
index 6837010f532..286bb49fbcf 100644
--- a/usr.sbin/pppd/auth.c
+++ b/usr.sbin/pppd/auth.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: auth.c,v 1.33 2014/11/13 06:19:51 schwarze Exp $ */
+/* $OpenBSD: auth.c,v 1.34 2015/01/16 06:40:19 deraadt Exp $ */
/*
* auth.c - PPP authentication and phase control.
@@ -77,6 +77,7 @@
#include <stddef.h>
#include <stdlib.h>
#include <unistd.h>
+#include <limits.h>
#include <syslog.h>
#include <pwd.h>
#include <string.h>
@@ -552,7 +553,7 @@ auth_check_options()
/* Default our_name to hostname, and user to our_name */
if (our_name[0] == 0 || usehostname)
- strlcpy(our_name, hostname, MAXHOSTNAMELEN);
+ strlcpy(our_name, hostname, HOST_NAME_MAX+1);
if (user[0] == 0)
strlcpy(user, our_name, MAXNAMELEN);
diff --git a/usr.sbin/pppd/demand.c b/usr.sbin/pppd/demand.c
index fda74ca5faa..5d09d0beb19 100644
--- a/usr.sbin/pppd/demand.c
+++ b/usr.sbin/pppd/demand.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: demand.c,v 1.10 2011/04/30 18:49:38 nicm Exp $ */
+/* $OpenBSD: demand.c,v 1.11 2015/01/16 06:40:19 deraadt Exp $ */
/*
* demand.c - Support routines for demand-dialling.
@@ -35,14 +35,6 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <syslog.h>
-#include <netdb.h>
-#include <sys/param.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/time.h>
@@ -54,6 +46,12 @@
#include <net/bpf.h>
#include <pcap.h>
#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <syslog.h>
#include "pppd.h"
#include "fsm.h"
diff --git a/usr.sbin/pppd/ipcp.c b/usr.sbin/pppd/ipcp.c
index 1577557ab77..245f73fc28c 100644
--- a/usr.sbin/pppd/ipcp.c
+++ b/usr.sbin/pppd/ipcp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ipcp.c,v 1.13 2010/05/10 02:00:50 krw Exp $ */
+/* $OpenBSD: ipcp.c,v 1.14 2015/01/16 06:40:19 deraadt Exp $ */
/*
* ipcp.c - PPP IP Control Protocol.
@@ -46,15 +46,14 @@
* TODO:
*/
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <syslog.h>
#include <netdb.h>
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
#include "pppd.h"
#include "fsm.h"
diff --git a/usr.sbin/pppd/main.c b/usr.sbin/pppd/main.c
index 7d74d74f92e..08ee24bb118 100644
--- a/usr.sbin/pppd/main.c
+++ b/usr.sbin/pppd/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.50 2014/10/08 04:51:29 deraadt Exp $ */
+/* $OpenBSD: main.c,v 1.51 2015/01/16 06:40:19 deraadt Exp $ */
/*
* main.c - Point-to-Point Protocol main module
@@ -42,11 +42,19 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <sys/stat.h>
+#include <sys/socket.h>
+#include <net/if.h>
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <limits.h>
#include <signal.h>
#include <errno.h>
#include <fcntl.h>
@@ -54,14 +62,6 @@
#include <netdb.h>
#include <utmp.h>
#include <pwd.h>
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <sys/stat.h>
-#include <sys/socket.h>
-#include <net/if.h>
#include "pppd.h"
#include "magic.h"
@@ -91,9 +91,9 @@ char ifname[IFNAMSIZ]; /* Interface name */
int ifunit; /* Interface unit number */
char *progname; /* Name of this program */
-char hostname[MAXHOSTNAMELEN]; /* Our hostname */
-static char pidfilename[MAXPATHLEN]; /* name of pid file */
-static char default_devnam[MAXPATHLEN]; /* name of default device */
+char hostname[HOST_NAME_MAX+1]; /* Our hostname */
+static char pidfilename[PATH_MAX]; /* name of pid file */
+static char default_devnam[PATH_MAX]; /* name of default device */
static pid_t pid; /* Our pid */
static uid_t uid; /* Our real user-id */
static int conn_running; /* we have a [dis]connector running */
@@ -194,7 +194,7 @@ main(argc, argv)
phase = PHASE_INITIALIZE;
p = ttyname(0);
if (p)
- strlcpy(devnam, p, MAXPATHLEN);
+ strlcpy(devnam, p, PATH_MAX);
strlcpy(default_devnam, devnam, sizeof default_devnam);
script_env = NULL;
@@ -1217,11 +1217,9 @@ run_program(prog, args, must_exist)
dup2 (0, 2); /* stderr -> /dev/null */
}
-#ifdef BSD
/* Force the priority back to zero if pppd is running higher. */
if (setpriority (PRIO_PROCESS, 0, 0) < 0)
syslog (LOG_WARNING, "can't reset priority to 0: %m");
-#endif
/* SysV recommends a second fork at this point. */
diff --git a/usr.sbin/pppd/options.c b/usr.sbin/pppd/options.c
index 99c29d8e10f..349d498e789 100644
--- a/usr.sbin/pppd/options.c
+++ b/usr.sbin/pppd/options.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: options.c,v 1.27 2014/12/10 03:39:54 jsg Exp $ */
+/* $OpenBSD: options.c,v 1.28 2015/01/16 06:40:19 deraadt Exp $ */
/*
* options.c - handles option processing for PPP.
@@ -97,7 +97,7 @@ int dflag = 0; /* Tell libpcap we want debugging */
int debug = 0; /* Debug flag */
int kdebugflag = 0; /* Tell kernel to print debug messages */
int default_device = 1; /* Using /dev/tty or equivalent */
-char devnam[MAXPATHLEN] = "/dev/tty"; /* Device name */
+char devnam[PATH_MAX] = "/dev/tty"; /* Device name */
int crtscts = 0; /* Use hardware flow control */
int modem = 1; /* Use modem control lines */
int modem_chat = 0; /* Use modem control lines during chat */
@@ -1567,7 +1567,7 @@ setdevname(cp, quiet)
int quiet;
{
struct stat statbuf;
- char dev[MAXPATHLEN];
+ char dev[PATH_MAX];
if (*cp == 0)
return 0;
@@ -1588,7 +1588,7 @@ setdevname(cp, quiet)
return -1;
}
- (void) strlcpy(devnam, cp, MAXPATHLEN);
+ (void) strlcpy(devnam, cp, PATH_MAX);
default_device = FALSE;
devnam_info.priv = privileged_option;
devnam_info.source = option_source;
diff --git a/usr.sbin/pppd/pppd.h b/usr.sbin/pppd/pppd.h
index 815b8bed73a..eaef54aa4db 100644
--- a/usr.sbin/pppd/pppd.h
+++ b/usr.sbin/pppd/pppd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pppd.h,v 1.17 2011/04/30 18:49:38 nicm Exp $ */
+/* $OpenBSD: pppd.h,v 1.18 2015/01/16 06:40:19 deraadt Exp $ */
/*
* pppd.h - PPP daemon global declarations.
@@ -49,12 +49,11 @@
#ifndef __PPPD_H__
#define __PPPD_H__
-#include <stdio.h> /* for FILE */
-#include <stdarg.h>
-#include <sys/param.h> /* for MAXPATHLEN and BSD4_4, if defined */
#include <sys/types.h> /* for u_int32_t, if defined */
#include <sys/time.h> /* for struct timeval */
#include <net/ppp_defs.h>
+#include <stdio.h> /* for FILE */
+#include <stdarg.h>
/*
* Limits.
diff --git a/usr.sbin/pppd/pppstats/pppstats.c b/usr.sbin/pppd/pppstats/pppstats.c
index 0d0fde8840c..640ca0c82da 100644
--- a/usr.sbin/pppd/pppstats/pppstats.c
+++ b/usr.sbin/pppd/pppstats/pppstats.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pppstats.c,v 1.10 2009/10/27 23:59:53 deraadt Exp $ */
+/* $OpenBSD: pppstats.c,v 1.11 2015/01/16 06:40:19 deraadt Exp $ */
/*
* print PPP statistics:
@@ -47,6 +47,12 @@
* SUCH DAMAGE.
*/
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <net/ppp_defs.h>
+#include <net/if.h>
+#include <net/if_ppp.h>
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
@@ -57,13 +63,6 @@
#include <fcntl.h>
#include <err.h>
#include <unistd.h>
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <net/ppp_defs.h>
-#include <net/if.h>
-#include <net/if_ppp.h>
int vflag, rflag, zflag; /* select type of display */
int aflag; /* print absolute values, not deltas */