summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2019-07-03 03:24:05 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2019-07-03 03:24:05 +0000
commit75fca2aa3a35362ecff27f0c3041d3f511b51275 (patch)
treed0c647e96313c8d94edf3f50304b78ae1cf249c1 /usr.sbin
parentaef6c060ee15355c0490999de3c4679d7bb97e84 (diff)
snprintf/vsnprintf return < 0 on error, rather than -1.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/bgpd/util.c6
-rw-r--r--usr.sbin/cron/atrun.c8
-rw-r--r--usr.sbin/hostapd/hostapd.c4
-rw-r--r--usr.sbin/identd/identd.c4
-rw-r--r--usr.sbin/installboot/util.c6
-rw-r--r--usr.sbin/iscsid/pdu.c4
-rw-r--r--usr.sbin/ldapd/util.c4
-rw-r--r--usr.sbin/lpd/printer.c4
-rw-r--r--usr.sbin/lpr/common_source/rmjob.c6
-rw-r--r--usr.sbin/lpr/common_source/startdaemon.c6
-rw-r--r--usr.sbin/lpr/lpd/printjob.c18
-rw-r--r--usr.sbin/radiusd/util.c4
-rw-r--r--usr.sbin/smtpd/envelope.c6
-rw-r--r--usr.sbin/smtpd/mail.maildir.c8
-rw-r--r--usr.sbin/smtpd/smtp_session.c4
-rw-r--r--usr.sbin/smtpd/util.c4
-rw-r--r--usr.sbin/tcpdump/print-bgp.c6
-rw-r--r--usr.sbin/tftpd/tftpd.c6
-rw-r--r--usr.sbin/user/user.c4
-rw-r--r--usr.sbin/ypserv/ypserv/ypserv_db.c4
20 files changed, 59 insertions, 57 deletions
diff --git a/usr.sbin/bgpd/util.c b/usr.sbin/bgpd/util.c
index 4ec98fd9b16..44e6cd151fd 100644
--- a/usr.sbin/bgpd/util.c
+++ b/usr.sbin/bgpd/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.50 2019/06/17 13:35:43 claudio Exp $ */
+/* $OpenBSD: util.c,v 1.51 2019/07/03 03:24:02 deraadt Exp $ */
/*
* Copyright (c) 2006 Claudio Jeker <claudio@openbsd.org>
@@ -104,7 +104,7 @@ log_as(u_int32_t as)
{
static char buf[11]; /* "4294967294\0" */
- if (snprintf(buf, sizeof(buf), "%u", as) == -1)
+ if (snprintf(buf, sizeof(buf), "%u", as) < 0)
return ("?");
return (buf);
@@ -206,7 +206,7 @@ aspath_snprint(char *buf, size_t size, void *data, u_int16_t len)
{
#define UPDATE() \
do { \
- if (r == -1) \
+ if (r < 0) \
return (-1); \
total_size += r; \
if ((unsigned int)r < size) { \
diff --git a/usr.sbin/cron/atrun.c b/usr.sbin/cron/atrun.c
index d03eee04dbb..ca5f307b9d7 100644
--- a/usr.sbin/cron/atrun.c
+++ b/usr.sbin/cron/atrun.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: atrun.c,v 1.50 2019/06/28 13:32:47 deraadt Exp $ */
+/* $OpenBSD: atrun.c,v 1.51 2019/07/03 03:24:03 deraadt Exp $ */
/*
* Copyright (c) 2002-2003 Todd C. Miller <millert@openbsd.org>
@@ -189,7 +189,7 @@ atrun(at_db *db, double batch_maxload, time_t now)
len = snprintf(atfile, sizeof(atfile), "%lld.%c",
(long long)job->run_time, job->queue);
- if (len >= sizeof(atfile)) {
+ if (len < 0 || len >= sizeof(atfile)) {
TAILQ_REMOVE(&db->jobs, job, entries);
free(job);
continue;
@@ -234,7 +234,9 @@ atrun(at_db *db, double batch_maxload, time_t now)
) {
len = snprintf(atfile, sizeof(atfile), "%lld.%c",
(long long)batch->run_time, batch->queue);
- if (len < sizeof(atfile))
+ if (len < 0 || len >= sizeof(atfile))
+ ;
+ else
run_job(batch, dfd, atfile);
TAILQ_REMOVE(&db->jobs, batch, entries);
free(job);
diff --git a/usr.sbin/hostapd/hostapd.c b/usr.sbin/hostapd/hostapd.c
index 49085569573..0371693d013 100644
--- a/usr.sbin/hostapd/hostapd.c
+++ b/usr.sbin/hostapd/hostapd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hostapd.c,v 1.40 2019/06/28 13:32:47 deraadt Exp $ */
+/* $OpenBSD: hostapd.c,v 1.41 2019/07/03 03:24:03 deraadt Exp $ */
/*
* Copyright (c) 2004, 2005 Reyk Floeter <reyk@openbsd.org>
@@ -109,7 +109,7 @@ hostapd_printf(const char *fmt, ...)
goto va_flush;
if (strlcpy(newfmt + n, fmt, sizeof(newfmt) - n) >= sizeof(newfmt) - n)
goto va_flush;
- if (vsnprintf(printbuf, sizeof(printbuf), newfmt, ap) == -1)
+ if (vsnprintf(printbuf, sizeof(printbuf), newfmt, ap) < 0)
goto va_flush;
va_end(ap);
diff --git a/usr.sbin/identd/identd.c b/usr.sbin/identd/identd.c
index f0ffc612499..b14d8dc2970 100644
--- a/usr.sbin/identd/identd.c
+++ b/usr.sbin/identd/identd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: identd.c,v 1.39 2018/01/05 08:13:31 mpi Exp $ */
+/* $OpenBSD: identd.c,v 1.40 2019/07/03 03:24:03 deraadt Exp $ */
/*
* Copyright (c) 2013 David Gwynne <dlg@openbsd.org>
@@ -469,7 +469,7 @@ parent_noident(struct ident_resolver *r, struct passwd *pw)
int rv;
rv = snprintf(path, sizeof(path), "%s/%s", pw->pw_dir, DOTNOIDENT);
- if (rv == -1 || rv >= sizeof(path)) {
+ if (rv < 0 || rv >= sizeof(path)) {
r->error = E_UNKNOWN;
return;
}
diff --git a/usr.sbin/installboot/util.c b/usr.sbin/installboot/util.c
index 305362f3a1c..ba5ee2f0e9c 100644
--- a/usr.sbin/installboot/util.c
+++ b/usr.sbin/installboot/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.13 2018/11/07 04:51:56 miko Exp $ */
+/* $OpenBSD: util.c,v 1.14 2019/07/03 03:24:03 deraadt Exp $ */
/*
* Copyright (c) 2014 Joel Sing <jsing@openbsd.org>
@@ -107,7 +107,7 @@ fileprefix(const char *base, const char *path)
return (NULL);
}
n = snprintf(s, PATH_MAX, "%s/%s", base, path);
- if (n < 1 || n >= PATH_MAX) {
+ if (n < 0 || n >= PATH_MAX) {
warn("snprintf");
goto err;
}
@@ -124,7 +124,7 @@ fileprefix(const char *base, const char *path)
goto err;
}
n = snprintf(s, PATH_MAX, "%s/%s", r, b);
- if (n < 1 || n >= PATH_MAX) {
+ if (n < 0 || n >= PATH_MAX) {
warn("snprintf");
goto err;
}
diff --git a/usr.sbin/iscsid/pdu.c b/usr.sbin/iscsid/pdu.c
index d498882d67c..37e2f81d543 100644
--- a/usr.sbin/iscsid/pdu.c
+++ b/usr.sbin/iscsid/pdu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pdu.c,v 1.11 2015/12/05 06:38:18 mmcc Exp $ */
+/* $OpenBSD: pdu.c,v 1.12 2019/07/03 03:24:03 deraadt Exp $ */
/*
* Copyright (c) 2009 Claudio Jeker <claudio@openbsd.org>
@@ -75,7 +75,7 @@ text_to_pdu(struct kvp *k, struct pdu *p)
nk = 0;
while(k[nk].key) {
n = snprintf(s, rem, "%s=%s", k[nk].key, k[nk].value);
- if (n == -1 || (size_t)n >= rem)
+ if (n < 0 || (size_t)n >= rem)
fatalx("text_to_pdu");
rem -= n + 1;
s += n + 1;
diff --git a/usr.sbin/ldapd/util.c b/usr.sbin/ldapd/util.c
index eb72d949dcb..cc94ebf74d2 100644
--- a/usr.sbin/ldapd/util.c
+++ b/usr.sbin/ldapd/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.10 2018/05/15 11:19:21 reyk Exp $ */
+/* $OpenBSD: util.c,v 1.11 2019/07/03 03:24:03 deraadt Exp $ */
/*
* Copyright (c) 2009 Martin Hedenfalk <martin@bzero.se>
@@ -43,7 +43,7 @@ bsnprintf(char *str, size_t size, const char *format, ...)
va_start(ap, format);
ret = vsnprintf(str, size, format, ap);
va_end(ap);
- if (ret == -1 || ret >= (int)size)
+ if (ret < 0 || ret >= size)
return 0;
return 1;
diff --git a/usr.sbin/lpd/printer.c b/usr.sbin/lpd/printer.c
index 7782b4c5307..b6743f2a9c7 100644
--- a/usr.sbin/lpd/printer.c
+++ b/usr.sbin/lpd/printer.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: printer.c,v 1.1 2018/04/27 16:14:37 eric Exp $ */
+/* $OpenBSD: printer.c,v 1.2 2019/07/03 03:24:03 deraadt Exp $ */
/*
* Copyright (c) 2017 Eric Faurot <eric@openbsd.org>
@@ -848,7 +848,7 @@ sendcmd(const char *fmt, ...)
len = vsnprintf(line, sizeof(line), fmt, ap);
va_end(ap);
- if (len == -1) {
+ if (len < 0) {
log_warn("%s: vsnprintf", __func__);
return -1;
}
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;
}
diff --git a/usr.sbin/radiusd/util.c b/usr.sbin/radiusd/util.c
index 4c5b7bb1361..068bf8f0f5a 100644
--- a/usr.sbin/radiusd/util.c
+++ b/usr.sbin/radiusd/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.2 2015/08/27 01:02:35 yasuoka Exp $ */
+/* $OpenBSD: util.c,v 1.3 2019/07/03 03:24:03 deraadt Exp $ */
/*
* Copyright (c) 2013 Internet Initiative Japan Inc.
@@ -101,7 +101,7 @@ addrport_tostring(struct sockaddr *sa, socklen_t salen, char *buf, size_t lbuf)
return "error";
}
- if (ret == -1 || ret >= (int)lbuf)
+ if (ret < 0 || ret >= (int)lbuf)
return "(error)";
return (buf);
}
diff --git a/usr.sbin/smtpd/envelope.c b/usr.sbin/smtpd/envelope.c
index cd247a82c08..8e68a19f927 100644
--- a/usr.sbin/smtpd/envelope.c
+++ b/usr.sbin/smtpd/envelope.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: envelope.c,v 1.42 2018/12/30 23:09:58 guenther Exp $ */
+/* $OpenBSD: envelope.c,v 1.43 2019/07/03 03:24:03 deraadt Exp $ */
/*
* Copyright (c) 2013 Eric Faurot <eric@openbsd.org>
@@ -59,7 +59,7 @@ envelope_set_errormsg(struct envelope *e, char *fmt, ...)
va_end(ap);
/* this should not happen */
- if (ret == -1)
+ if (ret < 0)
err(1, "vsnprintf");
if ((size_t)ret >= sizeof(e->errorline))
@@ -748,7 +748,7 @@ envelope_ascii_dump(const struct envelope *ep, char **dest, size_t *len,
return;
l = snprintf(*dest, *len, "%s: %s\n", field, buf);
- if (l == -1 || (size_t) l >= *len)
+ if (l < 0 || (size_t) l >= *len)
goto err;
*dest += l;
*len -= l;
diff --git a/usr.sbin/smtpd/mail.maildir.c b/usr.sbin/smtpd/mail.maildir.c
index cc9d5429aa1..a4956f1ba19 100644
--- a/usr.sbin/smtpd/mail.maildir.c
+++ b/usr.sbin/smtpd/mail.maildir.c
@@ -99,7 +99,7 @@ maildir_mkdirs(const char *dirname)
for (i = 0; i < nitems(subdirs); ++i) {
ret = snprintf(pathname, sizeof pathname, "%s/%s", dirname,
subdirs[i]);
- if (ret == -1 || (size_t)ret >= sizeof pathname)
+ if (ret < 0 || (size_t)ret >= sizeof pathname)
errc(1, ENAMETOOLONG, "%s/%s", dirname, subdirs[i]);
if (mkdir(pathname, 0700) == -1 && errno != EEXIST)
err(1, NULL);
@@ -137,7 +137,7 @@ maildir_engine(const char *dirname, int junk)
if ((home = getenv("HOME")) == NULL)
err(1, NULL);
ret = snprintf(rootpath, sizeof rootpath, "%s/Maildir", home);
- if (ret == -1 || (size_t)ret >= sizeof rootpath)
+ if (ret < 0 || (size_t)ret >= sizeof rootpath)
errc(1, ENAMETOOLONG, "%s/Maildir", home);
dirname = rootpath;
}
@@ -146,7 +146,7 @@ maildir_engine(const char *dirname, int junk)
if (junk) {
/* create Junk subdirectory */
ret = snprintf(junkpath, sizeof junkpath, "%s/.Junk", dirname);
- if (ret == -1 || (size_t)ret >= sizeof junkpath)
+ if (ret < 0 || (size_t)ret >= sizeof junkpath)
errc(1, ENAMETOOLONG, "%s/.Junk", dirname);
maildir_mkdirs(junkpath);
}
@@ -156,7 +156,7 @@ maildir_engine(const char *dirname, int junk)
subdir[0]) {
ret = snprintf(extpath, sizeof extpath, "%s/.%s",
dirname, subdir);
- if (ret == -1 || (size_t)ret >= sizeof extpath)
+ if (ret < 0 || (size_t)ret >= sizeof extpath)
errc(1, ENAMETOOLONG, "%s/.%s",
dirname, subdir);
if (stat(extpath, &sb) != -1) {
diff --git a/usr.sbin/smtpd/smtp_session.c b/usr.sbin/smtpd/smtp_session.c
index 67880cb0741..429fc5b610e 100644
--- a/usr.sbin/smtpd/smtp_session.c
+++ b/usr.sbin/smtpd/smtp_session.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtp_session.c,v 1.394 2019/06/28 13:32:51 deraadt Exp $ */
+/* $OpenBSD: smtp_session.c,v 1.395 2019/07/03 03:24:03 deraadt Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -2046,7 +2046,7 @@ smtp_reply(struct smtp_session *s, char *fmt, ...)
va_start(ap, fmt);
n = vsnprintf(buf, sizeof buf, fmt, ap);
va_end(ap);
- if (n == -1 || n >= LINE_MAX)
+ if (n < 0 || n >= LINE_MAX)
fatalx("smtp_reply: line too long");
if (n < 4)
fatalx("smtp_reply: response too short");
diff --git a/usr.sbin/smtpd/util.c b/usr.sbin/smtpd/util.c
index b1d95aac0fe..30fea943cae 100644
--- a/usr.sbin/smtpd/util.c
+++ b/usr.sbin/smtpd/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.141 2019/06/28 13:32:51 deraadt Exp $ */
+/* $OpenBSD: util.c,v 1.142 2019/07/03 03:24:03 deraadt Exp $ */
/*
* Copyright (c) 2000,2001 Markus Friedl. All rights reserved.
@@ -176,7 +176,7 @@ bsnprintf(char *str, size_t size, const char *format, ...)
va_start(ap, format);
ret = vsnprintf(str, size, format, ap);
va_end(ap);
- if (ret == -1 || ret >= (int)size)
+ if (ret < 0 || ret >= (int)size)
return 0;
return 1;
diff --git a/usr.sbin/tcpdump/print-bgp.c b/usr.sbin/tcpdump/print-bgp.c
index 96bfd6d7a09..8a0f1699ba1 100644
--- a/usr.sbin/tcpdump/print-bgp.c
+++ b/usr.sbin/tcpdump/print-bgp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: print-bgp.c,v 1.28 2019/05/11 13:13:47 claudio Exp $ */
+/* $OpenBSD: print-bgp.c,v 1.29 2019/07/03 03:24:03 deraadt Exp $ */
/*
* Copyright (C) 1999 WIDE Project.
@@ -384,7 +384,7 @@ decode_prefix4(const u_char *pd, char *buf, u_int buflen)
((0xff00 >> (plen % 8)) & 0xff);
}
n = snprintf(buf, buflen, "%s/%u", getname((u_char *)&addr), plen);
- if (n == -1 || n >= buflen)
+ if (n < 0 || n >= buflen)
return -1;
return 1 + (plen + 7) / 8;
@@ -414,7 +414,7 @@ decode_prefix6(const u_char *pd, char *buf, u_int buflen)
}
n = snprintf(buf, buflen, "%s/%u", getname6((u_char *)&addr), plen);
- if (n == -1 || n >= buflen)
+ if (n < 0 || n >= buflen)
return -1;
return 1 + (plen + 7) / 8;
diff --git a/usr.sbin/tftpd/tftpd.c b/usr.sbin/tftpd/tftpd.c
index 5dd3533a2cd..4c0316d6463 100644
--- a/usr.sbin/tftpd/tftpd.c
+++ b/usr.sbin/tftpd/tftpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tftpd.c,v 1.42 2019/06/28 13:32:51 deraadt Exp $ */
+/* $OpenBSD: tftpd.c,v 1.43 2019/07/03 03:24:03 deraadt Exp $ */
/*
* Copyright (c) 2012 David Gwynne <dlg@uq.edu.au>
@@ -991,7 +991,7 @@ validate_access(struct tftp_client *client, const char *requested)
*/
ret = snprintf(rewritten, sizeof(rewritten), "%s/%s",
getip(&client->ss), requested);
- if (ret == -1 || ret >= sizeof(rewritten))
+ if (ret < 0 || ret >= sizeof(rewritten))
return (ENAMETOOLONG + 100);
filename = rewritten;
} else {
@@ -1502,7 +1502,7 @@ oack(struct tftp_client *client)
n = snprintf(bp, size, "%s%c%lld", opt_names[i], '\0',
options[i].o_reply);
- if (n == -1 || n >= size) {
+ if (n < 0 || n >= size) {
lwarnx("oack: no buffer space");
goto error;
}
diff --git a/usr.sbin/user/user.c b/usr.sbin/user/user.c
index 2e39803df59..03de2b5e0bb 100644
--- a/usr.sbin/user/user.c
+++ b/usr.sbin/user/user.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: user.c,v 1.126 2019/06/28 13:32:51 deraadt Exp $ */
+/* $OpenBSD: user.c,v 1.127 2019/07/03 03:24:03 deraadt Exp $ */
/* $NetBSD: user.c,v 1.69 2003/04/14 17:40:07 agc Exp $ */
/*
@@ -1165,7 +1165,7 @@ adduser(char *login_name, user_t *up)
if (yp) {
/* put back the + line */
cc = snprintf(buf, sizeof(buf), "+:*::::::::\n");
- if (cc == -1 || cc >= sizeof(buf)) {
+ if (cc < 0 || cc >= sizeof(buf)) {
close(ptmpfd);
pw_abort();
errx(EXIT_FAILURE, "can't add `%s', line too long", buf);
diff --git a/usr.sbin/ypserv/ypserv/ypserv_db.c b/usr.sbin/ypserv/ypserv/ypserv_db.c
index 9b05da17a6e..f2caeca5204 100644
--- a/usr.sbin/ypserv/ypserv/ypserv_db.c
+++ b/usr.sbin/ypserv/ypserv/ypserv_db.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ypserv_db.c,v 1.30 2015/12/08 07:16:33 mmcc Exp $ */
+/* $OpenBSD: ypserv_db.c,v 1.31 2019/07/03 03:24:03 deraadt Exp $ */
/*
* Copyright (c) 1994 Mats O Jansson <moj@stacken.kth.se>
@@ -422,7 +422,7 @@ lookup_host(int nametable, int host_lookup, DBM *db, char *keystr,
}
len = snprintf(val, sizeof(val), "%s %s", keystr, host->h_name);
- if (len == (size_t)-1 || len >= sizeof(val))
+ if (len < 0 || len >= sizeof(val))
return(YP_YPERR);
v = val + len;
while ((ptr = *(host->h_aliases)) != NULL) {