summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1998-06-23 22:40:56 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1998-06-23 22:40:56 +0000
commit30cb72a00b8cc59895c391cad0f8e31611611ec4 (patch)
tree3e2f67dd80af3489363cf0596b740c6533994e40 /usr.sbin
parent325437057bbda9490b174c8fc6dc8f0e14a8f145 (diff)
Fix snprintf return value usage.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/ctm/ctm_dequeue/ctm_dequeue.c4
-rw-r--r--usr.sbin/lpr/common_source/displayq.c8
-rw-r--r--usr.sbin/named/named/db_dump.c6
-rw-r--r--usr.sbin/syslogd/syslogd.c2
4 files changed, 11 insertions, 9 deletions
diff --git a/usr.sbin/ctm/ctm_dequeue/ctm_dequeue.c b/usr.sbin/ctm/ctm_dequeue/ctm_dequeue.c
index f98a70beab0..45e9c8358a3 100644
--- a/usr.sbin/ctm/ctm_dequeue/ctm_dequeue.c
+++ b/usr.sbin/ctm/ctm_dequeue/ctm_dequeue.c
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: ctm_dequeue.c,v 1.2 1997/06/24 02:52:42 dgregor Exp $
+ * $Id: ctm_dequeue.c,v 1.3 1998/06/23 22:40:33 millert Exp $
*/
/*
@@ -126,7 +126,7 @@ main(int argc, char **argv)
#undef IGNORE
#undef HASNEXT
- if (snprintf(filename, len, "%s/%s", queue_dir, ftsent->fts_name) > len)
+ if (snprintf(filename, len, "%s/%s", queue_dir, ftsent->fts_name) >= len)
err("snprintf(filename) longer than buffer");
fp = open(filename, O_RDONLY, 0);
diff --git a/usr.sbin/lpr/common_source/displayq.c b/usr.sbin/lpr/common_source/displayq.c
index f6cabab4699..efb9301f554 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.9 1998/02/27 11:33:41 deraadt Exp $ */
+/* $OpenBSD: displayq.c,v 1.10 1998/06/23 22:40:34 millert Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)displayq.c 8.4 (Berkeley) 4/28/95";
#else
-static char rcsid[] = "$OpenBSD: displayq.c,v 1.9 1998/02/27 11:33:41 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: displayq.c,v 1.10 1998/06/23 22:40:34 millert Exp $";
#endif
#endif /* not lint */
@@ -235,7 +235,7 @@ displayq(format)
cp += strlen(cp);
for (i = 0; i < requests && cp-line < sizeof(line) - 1; i++) {
len = line + sizeof line - cp;
- if (snprintf(cp, len, " %d", requ[i]) > len) {
+ if (snprintf(cp, len, " %d", requ[i]) >= len) {
cp += strlen(cp);
break;
}
@@ -243,7 +243,7 @@ displayq(format)
}
for (i = 0; i < users && cp-line < sizeof(line) - 1; i++) {
len = line + sizeof line - cp;
- if (snprintf(cp, len, " %s", user[i]) > len) {
+ if (snprintf(cp, len, " %s", user[i]) >= len) {
cp += strlen(cp);
break;
}
diff --git a/usr.sbin/named/named/db_dump.c b/usr.sbin/named/named/db_dump.c
index 56baabb0073..b98310aa7b0 100644
--- a/usr.sbin/named/named/db_dump.c
+++ b/usr.sbin/named/named/db_dump.c
@@ -1,11 +1,11 @@
-/* $OpenBSD: db_dump.c,v 1.3 1997/04/27 23:09:42 deraadt Exp $ */
+/* $OpenBSD: db_dump.c,v 1.4 1998/06/23 22:40:36 millert Exp $ */
#if !defined(lint) && !defined(SABER)
#if 0
static char sccsid[] = "@(#)db_dump.c 4.33 (Berkeley) 3/3/91";
static char rcsid[] = "$From: db_dump.c,v 8.19 1996/10/08 04:51:03 vixie Exp $";
#else
-static char rcsid[] = "$OpenBSD: db_dump.c,v 1.3 1997/04/27 23:09:42 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: db_dump.c,v 1.4 1998/06/23 22:40:36 millert Exp $";
#endif
#endif /* not lint */
@@ -1025,7 +1025,7 @@ btoa(inbuf, inbuflen, outbuf, outbuflen)
by 'x' */
len = snprintf(outp, endoutp - outp,
"x %d %lx %lx %lx", inbuflen, Ceor, Csum, Crot);
- if (len >= outbuflen)
+ if (len >= endoutp - outp)
return(CONV_OVERFLOW);
else
return(CONV_SUCCESS);
diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c
index d04449d59e6..fedc0d8d131 100644
--- a/usr.sbin/syslogd/syslogd.c
+++ b/usr.sbin/syslogd/syslogd.c
@@ -651,6 +651,8 @@ fprintlog(f, flags, msg)
v->iov_len = snprintf(greetings, sizeof(greetings),
"\r\n\7Message from syslogd@%s at %.24s ...\r\n",
f->f_prevhost, ctime(&now));
+ if (v->iov_len >= sizeof(greetings))
+ v->iov_len = sizeof(greetings) - 1;
v++;
v->iov_base = "";
v->iov_len = 0;