diff options
author | deraadt <deraadt@openbsd.org> | 2019-07-03 03:24:01 +0000 |
---|---|---|
committer | deraadt <deraadt@openbsd.org> | 2019-07-03 03:24:01 +0000 |
commit | 515e489c3d599b9cfcdf9cf6842ac49f92e154d6 (patch) | |
tree | 9ce211473951e1baf5c99e08c2c35012292670f1 /usr.sbin/lpr | |
parent | sync (diff) | |
download | wireguard-openbsd-515e489c3d599b9cfcdf9cf6842ac49f92e154d6.tar.xz wireguard-openbsd-515e489c3d599b9cfcdf9cf6842ac49f92e154d6.zip |
snprintf/vsnprintf return < 0 on error, rather than -1.
Diffstat (limited to 'usr.sbin/lpr')
-rw-r--r-- | usr.sbin/lpr/common_source/rmjob.c | 6 | ||||
-rw-r--r-- | usr.sbin/lpr/common_source/startdaemon.c | 6 | ||||
-rw-r--r-- | usr.sbin/lpr/lpd/printjob.c | 18 |
3 files changed, 15 insertions, 15 deletions
diff --git a/usr.sbin/lpr/common_source/rmjob.c b/usr.sbin/lpr/common_source/rmjob.c index 0479e222003..69945619cb4 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.23 2016/01/12 23:35:13 tb Exp $ */ +/* $OpenBSD: rmjob.c,v 1.24 2019/07/03 03:24:03 deraadt Exp $ */ /* $NetBSD: rmjob.c,v 1.16 2000/04/16 14:43:58 mrg Exp $ */ /* @@ -339,7 +339,7 @@ rmremote(void) /* the trailing space will be replaced with a newline later */ n = snprintf(buf, sizeof(buf), "\5%s %s ", RP, all ? "-all" : person); - if (n == -1 || n >= sizeof(buf)) + if (n < 0 || n >= sizeof(buf)) goto bad; cp = buf + n; for (i = 0; i < users; i++) { @@ -352,7 +352,7 @@ rmremote(void) *cp = '\0'; for (i = 0; i < requests; i++) { n = snprintf(cp, sizeof(buf) - (cp - buf), "%d ", requ[i]); - if (n == -1 || n >= sizeof(buf) - (cp - buf)) + if (n < 0 || n >= sizeof(buf) - (cp - buf)) goto bad; cp += n; } diff --git a/usr.sbin/lpr/common_source/startdaemon.c b/usr.sbin/lpr/common_source/startdaemon.c index aec300c4910..cb2551d9518 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.17 2015/10/27 15:23:28 millert Exp $ */ +/* $OpenBSD: startdaemon.c,v 1.18 2019/07/03 03:24:03 deraadt Exp $ */ /* $NetBSD: startdaemon.c,v 1.10 1998/07/18 05:04:39 lukem Exp $ */ /* @@ -82,8 +82,8 @@ startdaemon(char *printer) } PRIV_END; siginterrupt(SIGINT, 0); - if ((n = snprintf(buf, sizeof(buf), "\1%s\n", printer)) >= sizeof(buf) || - n == -1) { + if ((n = snprintf(buf, sizeof(buf), "\1%s\n", printer)) < 0 || + n >= sizeof(buf)) { close(s); return (0); } diff --git a/usr.sbin/lpr/lpd/printjob.c b/usr.sbin/lpr/lpd/printjob.c index ff9428359f1..49c31626e64 100644 --- a/usr.sbin/lpr/lpd/printjob.c +++ b/usr.sbin/lpr/lpd/printjob.c @@ -1,4 +1,4 @@ -/* $OpenBSD: printjob.c,v 1.60 2018/04/26 12:42:51 guenther Exp $ */ +/* $OpenBSD: printjob.c,v 1.61 2019/07/03 03:24:03 deraadt Exp $ */ /* $NetBSD: printjob.c,v 1.31 2002/01/21 14:42:30 wiz Exp $ */ /* @@ -187,8 +187,8 @@ printjob(void) * write process id for others to know */ pid = getpid(); - if ((pidoff = i = snprintf(line, sizeof(line), "%d\n", pid)) >= - sizeof(line) || pidoff == -1) { + if ((pidoff = i = snprintf(line, sizeof(line), "%d\n", pid)) < 0 || + i >= sizeof(line)) { syslog(LOG_ERR, "impossibly large pid: %u", pid); exit(1); } @@ -230,8 +230,8 @@ again: fino = (ino_t)-1; (void)lseek(lfd, pidoff, SEEK_SET); - if ((i = snprintf(line, sizeof(line), "%s\n", q->q_name)) >= - sizeof(line) || i == -1) + if ((i = snprintf(line, sizeof(line), "%s\n", q->q_name)) < 0 || + i >= sizeof(line)) i = sizeof(line) - 1; /* can't happen */ if (write(lfd, line, i) != i) syslog(LOG_ERR, "%s: %s: %m", printer, LO); @@ -913,7 +913,7 @@ sendfile(int type, char *file) if (f == -1) return(ERROR); if ((amt = snprintf(buf, sizeof(buf), "%c%lld %s\n", type, - (long long)stb.st_size, file)) >= sizeof(buf) || amt == -1) + (long long)stb.st_size, file)) < 0 || amt >= sizeof(buf)) return (ACCESS); /* XXX hack */ for (i = 0; ; i++) { if (write(pfd, buf, amt) != amt || @@ -1483,8 +1483,8 @@ openrem(void) resp = -1; pfd = getport(RM, 0); if (pfd >= 0) { - if ((n = snprintf(line, sizeof(line), "\2%s\n", RP)) >= - sizeof(line) || n == -1) + if ((n = snprintf(line, sizeof(line), "\2%s\n", RP)) < 0 || + n >= sizeof(line)) n = sizeof(line) - 1; if (write(pfd, line, n) == n && (resp = response()) == '\0') @@ -1600,7 +1600,7 @@ pstatus(const char *msg, ...) ftruncate(fd, 0); len = vsnprintf(buf, sizeof(buf), msg, ap); va_end(ap); - if (len == -1) { + if (len < 0) { (void)close(fd); return; } |