summaryrefslogtreecommitdiffstats
path: root/usr.sbin/lpr
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/lpr
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/lpr')
-rw-r--r--usr.sbin/lpr/common_source/common.c4
-rw-r--r--usr.sbin/lpr/common_source/common_vars.c7
-rw-r--r--usr.sbin/lpr/common_source/displayq.c4
-rw-r--r--usr.sbin/lpr/common_source/lp.h4
-rw-r--r--usr.sbin/lpr/common_source/rmjob.c5
-rw-r--r--usr.sbin/lpr/common_source/startdaemon.c4
-rw-r--r--usr.sbin/lpr/lpc/cmds.c6
-rw-r--r--usr.sbin/lpr/lpc/lpc.c9
-rw-r--r--usr.sbin/lpr/lpd/key.c5
-rw-r--r--usr.sbin/lpr/lpd/lpd.c4
-rw-r--r--usr.sbin/lpr/lpd/modes.c3
-rw-r--r--usr.sbin/lpr/lpd/printjob.c8
-rw-r--r--usr.sbin/lpr/lpd/recvjob.c5
-rw-r--r--usr.sbin/lpr/lpq/lpq.c5
-rw-r--r--usr.sbin/lpr/lpr/lpr.c8
-rw-r--r--usr.sbin/lpr/lprm/lprm.c7
16 files changed, 45 insertions, 43 deletions
diff --git a/usr.sbin/lpr/common_source/common.c b/usr.sbin/lpr/common_source/common.c
index fd48614df1c..e2d4a063545 100644
--- a/usr.sbin/lpr/common_source/common.c
+++ b/usr.sbin/lpr/common_source/common.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: common.c,v 1.37 2014/11/02 13:56:55 deraadt Exp $ */
+/* $OpenBSD: common.c,v 1.38 2015/01/16 06:40:17 deraadt Exp $ */
/* $NetBSD: common.c,v 1.21 2000/08/09 14:28:50 itojun Exp $ */
/*
@@ -35,7 +35,6 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
#include <sys/stat.h>
#include <sys/time.h>
@@ -48,6 +47,7 @@
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
+#include <limits.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
diff --git a/usr.sbin/lpr/common_source/common_vars.c b/usr.sbin/lpr/common_source/common_vars.c
index a7cdb5fb494..372e7bae96b 100644
--- a/usr.sbin/lpr/common_source/common_vars.c
+++ b/usr.sbin/lpr/common_source/common_vars.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: common_vars.c,v 1.4 2009/10/27 23:59:51 deraadt Exp $ */
+/* $OpenBSD: common_vars.c,v 1.5 2015/01/16 06:40:17 deraadt Exp $ */
/* $NetBSD: common.c,v 1.15 1999/09/26 10:32:27 mrg Exp $ */
/*
@@ -35,13 +35,14 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
+#include <sys/types.h>
+#include <limits.h>
#include "pathnames.h"
char *name; /* program name */
char *printer; /* printer name */
-char host[MAXHOSTNAMELEN+1]; /* host machine name */
+char host[HOST_NAME_MAX+1 + 1]; /* host machine name */
char *from = host; /* client's machine name */
char *printcapdb[2] = { _PATH_PRINTCAP, 0 };
char *bp; /* pointer into printcap buffer. */
diff --git a/usr.sbin/lpr/common_source/displayq.c b/usr.sbin/lpr/common_source/displayq.c
index 5f3301e785b..0d401b7a7b5 100644
--- a/usr.sbin/lpr/common_source/displayq.c
+++ b/usr.sbin/lpr/common_source/displayq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: displayq.c,v 1.35 2014/05/21 18:38:42 pascal Exp $ */
+/* $OpenBSD: displayq.c,v 1.36 2015/01/16 06:40:17 deraadt Exp $ */
/* $NetBSD: displayq.c,v 1.21 2001/08/30 00:51:50 itojun Exp $ */
/*
@@ -30,7 +30,6 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
@@ -39,6 +38,7 @@
#include <errno.h>
#include <dirent.h>
#include <fcntl.h>
+#include <limits.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/usr.sbin/lpr/common_source/lp.h b/usr.sbin/lpr/common_source/lp.h
index 1c3307daba0..d1c997fd2e9 100644
--- a/usr.sbin/lpr/common_source/lp.h
+++ b/usr.sbin/lpr/common_source/lp.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: lp.h,v 1.18 2013/12/10 16:38:04 naddy Exp $ */
+/* $OpenBSD: lp.h,v 1.19 2015/01/16 06:40:17 deraadt Exp $ */
/* $NetBSD: lp.h,v 1.14 2000/04/16 14:43:58 mrg Exp $ */
/*
@@ -78,7 +78,7 @@ extern char line[BUFSIZ];
extern char *bp; /* pointer into printcap buffer */
extern char *printer; /* printer name */
/* host machine name */
-extern char host[MAXHOSTNAMELEN];
+extern char host[HOST_NAME_MAX+1];
extern char *from; /* client's machine name */
extern int remote; /* true if sending files to a remote host */
extern char *printcapdb[]; /* printcap database array */
diff --git a/usr.sbin/lpr/common_source/rmjob.c b/usr.sbin/lpr/common_source/rmjob.c
index f481a7aabf0..e58822aa349 100644
--- a/usr.sbin/lpr/common_source/rmjob.c
+++ b/usr.sbin/lpr/common_source/rmjob.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rmjob.c,v 1.21 2013/11/24 21:32:32 deraadt Exp $ */
+/* $OpenBSD: rmjob.c,v 1.22 2015/01/16 06:40:17 deraadt Exp $ */
/* $NetBSD: rmjob.c,v 1.16 2000/04/16 14:43:58 mrg Exp $ */
/*
@@ -30,13 +30,12 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
-
#include <signal.h>
#include <errno.h>
#include <fcntl.h>
#include <dirent.h>
#include <unistd.h>
+#include <limits.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
diff --git a/usr.sbin/lpr/common_source/startdaemon.c b/usr.sbin/lpr/common_source/startdaemon.c
index 6274215387f..84988f3e3ed 100644
--- a/usr.sbin/lpr/common_source/startdaemon.c
+++ b/usr.sbin/lpr/common_source/startdaemon.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: startdaemon.c,v 1.14 2014/07/20 01:38:40 guenther Exp $ */
+/* $OpenBSD: startdaemon.c,v 1.15 2015/01/16 06:40:17 deraadt Exp $ */
/* $NetBSD: startdaemon.c,v 1.10 1998/07/18 05:04:39 lukem Exp $ */
/*
@@ -30,7 +30,6 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
#include <sys/socket.h>
#include <sys/un.h>
@@ -39,6 +38,7 @@
#include <errno.h>
#include <stdio.h>
#include <unistd.h>
+#include <limits.h>
#include <string.h>
#include <signal.h>
diff --git a/usr.sbin/lpr/lpc/cmds.c b/usr.sbin/lpr/lpc/cmds.c
index bd73855b824..d27788c9429 100644
--- a/usr.sbin/lpr/lpc/cmds.c
+++ b/usr.sbin/lpr/lpc/cmds.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmds.c,v 1.26 2013/12/29 14:26:22 krw Exp $ */
+/* $OpenBSD: cmds.c,v 1.27 2015/01/16 06:40:18 deraadt Exp $ */
/* $NetBSD: cmds.c,v 1.12 1997/10/05 15:12:06 mrg Exp $ */
/*
@@ -35,7 +35,6 @@
* lpc -- line printer control program -- commands:
*/
-#include <sys/param.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/file.h>
@@ -45,6 +44,7 @@
#include <errno.h>
#include <dirent.h>
#include <unistd.h>
+#include <limits.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
@@ -189,7 +189,7 @@ static void
upstat(char *msg)
{
int fd;
- char statfile[MAXPATHLEN];
+ char statfile[PATH_MAX];
if (cgetstr(bp, "st", &ST) == -1)
ST = DEFSTAT;
diff --git a/usr.sbin/lpr/lpc/lpc.c b/usr.sbin/lpr/lpc/lpc.c
index 833a3369479..2661119f60d 100644
--- a/usr.sbin/lpr/lpc/lpc.c
+++ b/usr.sbin/lpr/lpc/lpc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lpc.c,v 1.18 2009/10/27 23:59:52 deraadt Exp $ */
+/* $OpenBSD: lpc.c,v 1.19 2015/01/16 06:40:18 deraadt Exp $ */
/* $NetBSD: lpc.c,v 1.11 2001/11/14 03:01:15 enami Exp $ */
/*
@@ -31,8 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
-
#include <dirent.h>
#include <signal.h>
#include <syslog.h>
@@ -41,6 +39,7 @@
#include <stdio.h>
#include <err.h>
#include <errno.h>
+#include <limits.h>
#include <ctype.h>
#include <string.h>
#include <grp.h>
@@ -278,7 +277,7 @@ static int
ingroup(char *grname)
{
static struct group *gptr = NULL;
- static gid_t groups[NGROUPS];
+ static gid_t groups[NGROUPS_MAX];
static int ngroups;
gid_t gid;
int i;
@@ -288,7 +287,7 @@ ingroup(char *grname)
warnx("Warning: unknown group `%s'", grname);
return(0);
}
- if ((ngroups = getgroups(NGROUPS, groups)) < 0)
+ if ((ngroups = getgroups(NGROUPS_MAX, groups)) < 0)
err(1, "getgroups");
}
gid = gptr->gr_gid;
diff --git a/usr.sbin/lpr/lpd/key.c b/usr.sbin/lpr/lpd/key.c
index be14b708fe7..a065494e44f 100644
--- a/usr.sbin/lpr/lpd/key.c
+++ b/usr.sbin/lpr/lpd/key.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: key.c,v 1.7 2009/10/27 23:59:52 deraadt Exp $ */
+/* $OpenBSD: key.c,v 1.8 2015/01/16 06:40:18 deraadt Exp $ */
/* $NetBSD: key.c,v 1.3 1997/10/20 08:08:28 scottr Exp $ */
/*-
@@ -30,15 +30,16 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
#include <sys/types.h>
#include <errno.h>
+#include <signal.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <syslog.h>
#include <dirent.h>
+#include <limits.h>
#include <termios.h>
#include "lp.h"
diff --git a/usr.sbin/lpr/lpd/lpd.c b/usr.sbin/lpr/lpd/lpd.c
index f6721e6990d..38b37e96c3f 100644
--- a/usr.sbin/lpr/lpd/lpd.c
+++ b/usr.sbin/lpr/lpd/lpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lpd.c,v 1.56 2014/10/17 06:11:27 deraadt Exp $ */
+/* $OpenBSD: lpd.c,v 1.57 2015/01/16 06:40:18 deraadt Exp $ */
/* $NetBSD: lpd.c,v 1.33 2002/01/21 14:42:29 wiz Exp $ */
/*
@@ -63,7 +63,6 @@
* Users can't touch the spool w/o the help of one of the lp* programs.
*/
-#include <sys/param.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <sys/socket.h>
@@ -86,6 +85,7 @@
#include <string.h>
#include <syslog.h>
#include <unistd.h>
+#include <limits.h>
#include "lp.h"
#include "lp.local.h"
diff --git a/usr.sbin/lpr/lpd/modes.c b/usr.sbin/lpr/lpd/modes.c
index b59fda51ad7..b62b18c0d0b 100644
--- a/usr.sbin/lpr/lpd/modes.c
+++ b/usr.sbin/lpr/lpd/modes.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: modes.c,v 1.7 2009/10/27 23:59:52 deraadt Exp $ */
+/* $OpenBSD: modes.c,v 1.8 2015/01/16 06:40:18 deraadt Exp $ */
/* $NetBSD: modes.c,v 1.3 1997/10/20 08:08:31 scottr Exp $ */
/*-
@@ -30,7 +30,6 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
#include <sys/types.h>
#include <stddef.h>
#include <string.h>
diff --git a/usr.sbin/lpr/lpd/printjob.c b/usr.sbin/lpr/lpd/printjob.c
index 226f299b458..5445a50ad6b 100644
--- a/usr.sbin/lpr/lpd/printjob.c
+++ b/usr.sbin/lpr/lpd/printjob.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: printjob.c,v 1.53 2014/12/16 03:35:49 millert Exp $ */
+/* $OpenBSD: printjob.c,v 1.54 2015/01/16 06:40:18 deraadt Exp $ */
/* $NetBSD: printjob.c,v 1.31 2002/01/21 14:42:30 wiz Exp $ */
/*
@@ -38,7 +38,6 @@
* it does not need to be removed because file locks are dynamic.
*/
-#include <sys/param.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <sys/types.h>
@@ -54,6 +53,7 @@
#include <errno.h>
#include <stdio.h>
#include <string.h>
+#include <limits.h>
#include <stdlib.h>
#include <stdarg.h>
#include <ctype.h>
@@ -91,12 +91,12 @@ static char title[80]; /* ``pr'' title */
static int tof; /* true if at top of form */
static char class[32]; /* classification field */
-static char fromhost[MAXHOSTNAMELEN]; /* user's host machine */
+static char fromhost[HOST_NAME_MAX+1]; /* user's host machine */
/* indentation size in static characters */
static char indent[10] = "-i0";
static char jobname[NAME_MAX]; /* job or file name */
static char length[10] = "-l"; /* page length in lines */
-static char logname[MAXLOGNAME]; /* user's login name */
+static char logname[LOGIN_NAME_MAX];/* user's login name */
static char pxlength[10] = "-y"; /* page length in pixels */
static char pxwidth[10] = "-x"; /* page width in pixels */
static char tempfile[] = "errsXXXXXXXXXX"; /* file name for filter output */
diff --git a/usr.sbin/lpr/lpd/recvjob.c b/usr.sbin/lpr/lpd/recvjob.c
index 5ab57f223d2..787da15b308 100644
--- a/usr.sbin/lpr/lpd/recvjob.c
+++ b/usr.sbin/lpr/lpd/recvjob.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: recvjob.c,v 1.25 2009/10/27 23:59:52 deraadt Exp $ */
+/* $OpenBSD: recvjob.c,v 1.26 2015/01/16 06:40:18 deraadt Exp $ */
/* $NetBSD: recvjob.c,v 1.14 2001/12/04 22:52:44 christos Exp $ */
/*
@@ -35,7 +35,7 @@
* Receive printer jobs from the network, queue them and
* start the printer daemon.
*/
-#include <sys/param.h>
+#include <sys/types.h>
#include <sys/mount.h>
#include <sys/stat.h>
@@ -49,6 +49,7 @@
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
+#include <limits.h>
#include "lp.h"
#include "lp.local.h"
#include "extern.h"
diff --git a/usr.sbin/lpr/lpq/lpq.c b/usr.sbin/lpr/lpq/lpq.c
index 934ec081ef1..6947dfb7fe2 100644
--- a/usr.sbin/lpr/lpq/lpq.c
+++ b/usr.sbin/lpr/lpq/lpq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lpq.c,v 1.20 2013/11/24 21:32:32 deraadt Exp $ */
+/* $OpenBSD: lpq.c,v 1.21 2015/01/16 06:40:18 deraadt Exp $ */
/* $NetBSD: lpq.c,v 1.9 1999/12/07 14:54:47 mrg Exp $ */
/*
@@ -41,15 +41,16 @@
* -P used to identify printer as per lpr/lprm
*/
-#include <sys/param.h>
#include <ctype.h>
+#include <signal.h>
#include <dirent.h>
#include <err.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
+#include <limits.h>
#include <syslog.h>
#include "lp.h"
diff --git a/usr.sbin/lpr/lpr/lpr.c b/usr.sbin/lpr/lpr/lpr.c
index dc13643acd6..5027435df47 100644
--- a/usr.sbin/lpr/lpr/lpr.c
+++ b/usr.sbin/lpr/lpr/lpr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lpr.c,v 1.46 2014/05/20 01:25:24 guenther Exp $ */
+/* $OpenBSD: lpr.c,v 1.47 2015/01/16 06:40:18 deraadt Exp $ */
/* $NetBSD: lpr.c,v 1.19 2000/10/11 20:23:52 is Exp $ */
/*
@@ -43,7 +43,6 @@
* using information from a printer data base.
*/
-#include <sys/param.h>
#include <sys/stat.h>
#include <sys/file.h>
@@ -55,6 +54,7 @@
#include <pwd.h>
#include <grp.h>
#include <unistd.h>
+#include <limits.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
@@ -109,7 +109,7 @@ main(int argc, char **argv)
struct passwd *pw;
struct group *gptr;
char *arg, *cp;
- char buf[MAXPATHLEN];
+ char buf[PATH_MAX];
int i, f, ch;
struct stat stb;
@@ -439,7 +439,7 @@ static char *
linked(char *file)
{
char *cp;
- static char buf[MAXPATHLEN];
+ static char buf[PATH_MAX];
int ret;
if (*file != '/') {
diff --git a/usr.sbin/lpr/lprm/lprm.c b/usr.sbin/lpr/lprm/lprm.c
index d29af91e6f7..0fa579e936b 100644
--- a/usr.sbin/lpr/lprm/lprm.c
+++ b/usr.sbin/lpr/lprm/lprm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lprm.c,v 1.20 2014/01/22 19:31:00 tobias Exp $ */
+/* $OpenBSD: lprm.c,v 1.21 2015/01/16 06:40:18 deraadt Exp $ */
/* $$NetBSD: lprm.c,v 1.9 1999/08/16 03:12:32 simonb Exp $ */
/*
@@ -42,9 +42,9 @@
* entries, otherwise one can only remove their own.
*/
-#include <sys/param.h>
#include <ctype.h>
+#include <signal.h>
#include <dirent.h>
#include <err.h>
#include <errno.h>
@@ -54,6 +54,7 @@
#include <string.h>
#include <syslog.h>
#include <unistd.h>
+#include <limits.h>
#include "lp.h"
#include "lp.local.h"
@@ -67,7 +68,7 @@ int requests; /* # of spool requests */
char *user[MAXUSERS]; /* users to process */
int users; /* # of users in user array */
volatile sig_atomic_t gotintr; /* set when we receive SIGINT */
-static char luser[MAXLOGNAME]; /* buffer for person */
+static char luser[LOGIN_NAME_MAX]; /* buffer for person */
static __dead void usage(void);