From 6ee8b26997adbf13785ab5146a6c1b146468d496 Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Tue, 29 Jul 1997 13:24:01 +0000 Subject: [PATCH] Two minor, pedantic fixes from bde for my last pedantic fixes, plus the following from recent OpenBSD changes. These changes (and all I've made) should be merged back into 2.2 when they are vetted in -current. common.c: OpenBSD 1.7: mickey: #if __STDC__ --> #ifdef __STDC__ displayq.c: OpenBSD 1.8: deraadt: 1 byte oflows; millert rmjob.c: OpenBSD 1.8: deraadt: 1 byte oflows; millert cmds.c: OpenBSD 1.9: grr: restore traditional "all" keyword option - see lpc(8) [[ This makes lpc status all work again -- imp ]] printjob.c: OpenBSD 1.17: deraadt: use sendmail -t OpenBSD 1.16: mickey: #if __STDC__ --> #ifdef __STDC__ OpenBSD 1.15: deraadt: 1 byte oflow; Don.Lewis@tsc.tdk.com recvjob.c: OpenBSD 1.11: mickey: #if __STDC__ --> #ifdef __STDC__ lpr.c: OpenBSD 1.19: mickey: #if __STDC__ --> #ifdef __STDC__ Obtained from: OpenBSD --- usr.sbin/lpr/common_source/common.c | 8 ++++---- usr.sbin/lpr/common_source/displayq.c | 4 ++-- usr.sbin/lpr/common_source/recvjob.c | 6 +++--- usr.sbin/lpr/common_source/rmjob.c | 2 +- usr.sbin/lpr/common_source/startdaemon.c | 2 +- usr.sbin/lpr/lpc/cmds.c | 2 +- usr.sbin/lpr/lpd/printjob.c | 12 +++++------- usr.sbin/lpr/lpd/recvjob.c | 6 +++--- usr.sbin/lpr/lpr/lpr.c | 8 ++++---- usr.sbin/lpr/runqueue/printjob.c | 12 +++++------- 10 files changed, 29 insertions(+), 33 deletions(-) diff --git a/usr.sbin/lpr/common_source/common.c b/usr.sbin/lpr/common_source/common.c index 6cb40984851e..b7960c2c12cf 100644 --- a/usr.sbin/lpr/common_source/common.c +++ b/usr.sbin/lpr/common_source/common.c @@ -308,7 +308,7 @@ checkremote() if (RM != NULL) { /* get the official name of the local host */ gethostname(name, sizeof(name)); - name[sizeof(name)-1] = '\0'; + name[sizeof(name) - 1] = '\0'; hp = gethostbyname(name); if (hp == (struct hostent *) NULL) { (void) snprintf(errbuf, sizeof(errbuf), @@ -352,14 +352,14 @@ delay(n) (void) select(0, (fd_set *)0, (fd_set *)0, (fd_set *)0, &tdelay); } -#if __STDC__ +#ifdef __STDC__ #include #else #include #endif void -#if __STDC__ +#ifdef __STDC__ fatal(const char *msg, ...) #else fatal(msg, va_alist) @@ -368,7 +368,7 @@ fatal(msg, va_alist) #endif { va_list ap; -#if __STDC__ +#ifdef __STDC__ va_start(ap, msg); #else va_start(ap); diff --git a/usr.sbin/lpr/common_source/displayq.c b/usr.sbin/lpr/common_source/displayq.c index eafaf0c8f30b..d326e79c4d13 100644 --- a/usr.sbin/lpr/common_source/displayq.c +++ b/usr.sbin/lpr/common_source/displayq.c @@ -224,12 +224,12 @@ displayq(format) putchar('\n'); (void) snprintf(line, sizeof(line), "%c%s", format + '\3', RP); cp = line; - for (i = 0; i < requests && cp-line+10 < sizeof(line); i++) { + for (i = 0; i < requests && cp-line+10 < sizeof(line) - 1; i++) { cp += strlen(cp); (void) sprintf(cp, " %d", requ[i]); } for (i = 0; i < users && cp - line + 1 + strlen(user[i]) < - sizeof(line); i++) { + sizeof(line) - 1; i++) { cp += strlen(cp); *cp++ = ' '; (void) strcpy(cp, user[i]); diff --git a/usr.sbin/lpr/common_source/recvjob.c b/usr.sbin/lpr/common_source/recvjob.c index 5c1d0277d903..6ed50c3a7637 100644 --- a/usr.sbin/lpr/common_source/recvjob.c +++ b/usr.sbin/lpr/common_source/recvjob.c @@ -336,14 +336,14 @@ rcleanup(signo) dfname[0] = '\0'; } -#if __STDC__ +#ifdef __STDC__ #include #else #include #endif static void -#if __STDC__ +#ifdef __STDC__ frecverr(const char *msg, ...) #else frecverr(msg, va_alist) @@ -352,7 +352,7 @@ frecverr(msg, va_alist) #endif { va_list ap; -#if __STDC__ +#ifdef __STDC__ va_start(ap, msg); #else va_start(ap); diff --git a/usr.sbin/lpr/common_source/rmjob.c b/usr.sbin/lpr/common_source/rmjob.c index c5f79d44863a..c44f1726c361 100644 --- a/usr.sbin/lpr/common_source/rmjob.c +++ b/usr.sbin/lpr/common_source/rmjob.c @@ -330,7 +330,7 @@ rmremote() *cp++ = ' '; strcpy(cp, user[i]); } - for (i = 0; i < requests && cp-buf+10 < sizeof(buf); i++) { + for (i = 0; i < requests && cp-buf+10 < sizeof(buf) - 1; i++) { cp += strlen(cp); (void) sprintf(cp, " %d", requ[i]); } diff --git a/usr.sbin/lpr/common_source/startdaemon.c b/usr.sbin/lpr/common_source/startdaemon.c index 13722f4533f6..ca24c82e35c6 100644 --- a/usr.sbin/lpr/common_source/startdaemon.c +++ b/usr.sbin/lpr/common_source/startdaemon.c @@ -83,7 +83,7 @@ startdaemon(printer) return(0); } seteuid(uid); - if (snprintf(buf, sizeof(buf), "\1%s\n", printer) > sizeof(buf)-1) { + if (snprintf(buf, sizeof(buf), "\1%s\n", printer) > sizeof(buf) - 1) { close(s); return (0); } diff --git a/usr.sbin/lpr/lpc/cmds.c b/usr.sbin/lpr/lpc/cmds.c index b772ed38cc2a..07ac45a3bb4d 100644 --- a/usr.sbin/lpr/lpc/cmds.c +++ b/usr.sbin/lpr/lpc/cmds.c @@ -771,7 +771,7 @@ status(argc, argv) register char *cp1, *cp2; char prbuf[100]; - if (argc == 1) { + if (argc == 1 || argc == 2 && !strcmp(argv[1], "all")) { printer = prbuf; while (cgetnext(&bp, printcapdb) > 0) { cp1 = prbuf; diff --git a/usr.sbin/lpr/lpd/printjob.c b/usr.sbin/lpr/lpd/printjob.c index 3d1400f1cb7b..b40a06dd0e98 100644 --- a/usr.sbin/lpr/lpd/printjob.c +++ b/usr.sbin/lpr/lpd/printjob.c @@ -1197,7 +1197,6 @@ sendmail(user, bombed) int dtablesize; int p[2], s; register char *cp; - char buf[100]; struct stat stb; FILE *fp; @@ -1211,8 +1210,7 @@ sendmail(user, bombed) cp++; else cp = _PATH_SENDMAIL; - sprintf(buf, "%s@%s", user, fromhost); - execl(_PATH_SENDMAIL, cp, buf, 0); + execl(_PATH_SENDMAIL, cp, "-t", 0); exit(0); } else if (s > 0) { /* parent */ dup2(p[1], 1); @@ -1620,14 +1618,14 @@ setty() } } -#if __STDC__ +#ifdef __STDC__ #include #else #include #endif static void -#if __STDC__ +#ifdef __STDC__ pstatus(const char *msg, ...) #else pstatus(msg, va_alist) @@ -1638,7 +1636,7 @@ pstatus(msg, va_alist) register int fd; char buf[BUFSIZ]; va_list ap; -#if __STDC__ +#ifdef __STDC__ va_start(ap, msg); #else va_start(ap); @@ -1651,7 +1649,7 @@ pstatus(msg, va_alist) exit(1); } ftruncate(fd, 0); - (void)vsnprintf(buf, sizeof(buf), msg, ap); + (void)vsnprintf(buf, sizeof(buf) - 1, msg, ap); va_end(ap); strcat(buf, "\n"); (void) write(fd, buf, strlen(buf)); diff --git a/usr.sbin/lpr/lpd/recvjob.c b/usr.sbin/lpr/lpd/recvjob.c index 5c1d0277d903..6ed50c3a7637 100644 --- a/usr.sbin/lpr/lpd/recvjob.c +++ b/usr.sbin/lpr/lpd/recvjob.c @@ -336,14 +336,14 @@ rcleanup(signo) dfname[0] = '\0'; } -#if __STDC__ +#ifdef __STDC__ #include #else #include #endif static void -#if __STDC__ +#ifdef __STDC__ frecverr(const char *msg, ...) #else frecverr(msg, va_alist) @@ -352,7 +352,7 @@ frecverr(msg, va_alist) #endif { va_list ap; -#if __STDC__ +#ifdef __STDC__ va_start(ap, msg); #else va_start(ap); diff --git a/usr.sbin/lpr/lpr/lpr.c b/usr.sbin/lpr/lpr/lpr.c index de0be2ab905a..a4f81d94968a 100644 --- a/usr.sbin/lpr/lpr/lpr.c +++ b/usr.sbin/lpr/lpr/lpr.c @@ -45,7 +45,7 @@ static char copyright[] = #ifndef lint static char sccsid[] = "From: @(#)lpr.c 8.4 (Berkeley) 4/28/95" - "\n$Id: lpr.c,v 1.18 1997/07/23 20:53:38 imp Exp $\n"; + "\n$Id: lpr.c,v 1.19 1997/07/29 04:17:19 imp Exp $\n"; #endif /* not lint */ /* @@ -760,14 +760,14 @@ lmktemp(id, num, len) return(s); } -#if __STDC__ +#ifdef __STDC__ #include #else #include #endif static void -#if __STDC__ +#ifdef __STDC__ fatal2(const char *msg, ...) #else fatal2(msg, va_alist) @@ -776,7 +776,7 @@ fatal2(msg, va_alist) #endif { va_list ap; -#if __STDC__ +#ifdef __STDC__ va_start(ap, msg); #else va_start(ap); diff --git a/usr.sbin/lpr/runqueue/printjob.c b/usr.sbin/lpr/runqueue/printjob.c index 3d1400f1cb7b..b40a06dd0e98 100644 --- a/usr.sbin/lpr/runqueue/printjob.c +++ b/usr.sbin/lpr/runqueue/printjob.c @@ -1197,7 +1197,6 @@ sendmail(user, bombed) int dtablesize; int p[2], s; register char *cp; - char buf[100]; struct stat stb; FILE *fp; @@ -1211,8 +1210,7 @@ sendmail(user, bombed) cp++; else cp = _PATH_SENDMAIL; - sprintf(buf, "%s@%s", user, fromhost); - execl(_PATH_SENDMAIL, cp, buf, 0); + execl(_PATH_SENDMAIL, cp, "-t", 0); exit(0); } else if (s > 0) { /* parent */ dup2(p[1], 1); @@ -1620,14 +1618,14 @@ setty() } } -#if __STDC__ +#ifdef __STDC__ #include #else #include #endif static void -#if __STDC__ +#ifdef __STDC__ pstatus(const char *msg, ...) #else pstatus(msg, va_alist) @@ -1638,7 +1636,7 @@ pstatus(msg, va_alist) register int fd; char buf[BUFSIZ]; va_list ap; -#if __STDC__ +#ifdef __STDC__ va_start(ap, msg); #else va_start(ap); @@ -1651,7 +1649,7 @@ pstatus(msg, va_alist) exit(1); } ftruncate(fd, 0); - (void)vsnprintf(buf, sizeof(buf), msg, ap); + (void)vsnprintf(buf, sizeof(buf) - 1, msg, ap); va_end(ap); strcat(buf, "\n"); (void) write(fd, buf, strlen(buf));