diff options
-rw-r--r-- | lib/libc/gen/getbsize.c | 4 | ||||
-rw-r--r-- | lib/libc/gen/setproctitle.c | 6 | ||||
-rw-r--r-- | libexec/telnetd/global.c | 6 | ||||
-rw-r--r-- | sbin/restore/dirs.c | 6 | ||||
-rw-r--r-- | sbin/restore/interactive.c | 6 | ||||
-rw-r--r-- | usr.bin/netstat/atalk.c | 17 | ||||
-rw-r--r-- | usr.bin/netstat/route.c | 28 | ||||
-rw-r--r-- | usr.bin/sed/main.c | 6 | ||||
-rw-r--r-- | usr.bin/vi/cl/cl_term.c | 2 | ||||
-rw-r--r-- | usr.bin/vi/common/api.c | 6 | ||||
-rw-r--r-- | usr.bin/vi/common/exf.c | 6 | ||||
-rw-r--r-- | usr.bin/vi/ex/ex_tag.c | 3 | ||||
-rw-r--r-- | usr.bin/vi/ex/ex_visual.c | 2 | ||||
-rw-r--r-- | usr.bin/vi/vi/v_at.c | 2 | ||||
-rw-r--r-- | usr.bin/vi/vi/v_increment.c | 4 | ||||
-rw-r--r-- | usr.bin/vi/vi/v_search.c | 4 | ||||
-rw-r--r-- | usr.bin/vi/vi/vs_line.c | 4 | ||||
-rw-r--r-- | usr.sbin/ctm/ctm_dequeue/ctm_dequeue.c | 4 | ||||
-rw-r--r-- | usr.sbin/lpr/common_source/displayq.c | 8 | ||||
-rw-r--r-- | usr.sbin/named/named/db_dump.c | 6 | ||||
-rw-r--r-- | usr.sbin/syslogd/syslogd.c | 2 |
21 files changed, 98 insertions, 34 deletions
diff --git a/lib/libc/gen/getbsize.c b/lib/libc/gen/getbsize.c index f3fbece28ff..9ecff68119c 100644 --- a/lib/libc/gen/getbsize.c +++ b/lib/libc/gen/getbsize.c @@ -32,7 +32,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: getbsize.c,v 1.5 1997/08/24 21:25:45 millert Exp $"; +static char rcsid[] = "$OpenBSD: getbsize.c,v 1.6 1998/06/23 22:40:25 millert Exp $"; #endif /* not lint */ #include <err.h> @@ -101,6 +101,8 @@ underflow: _warnx("%s: minimum blocksize is 512", p); blocksize = n = 512; *headerlenp = snprintf(header, sizeof(header), "%ld%s-blocks", n, form); + if (*headerlenp >= sizeof(header)) + *headerlenp = sizeof(header) - 1; *blocksizep = blocksize; return (header); } diff --git a/lib/libc/gen/setproctitle.c b/lib/libc/gen/setproctitle.c index 731c621461c..765cdeae056 100644 --- a/lib/libc/gen/setproctitle.c +++ b/lib/libc/gen/setproctitle.c @@ -30,7 +30,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: setproctitle.c,v 1.5 1997/07/25 20:30:03 mickey Exp $"; +static char rcsid[] = "$OpenBSD: setproctitle.c,v 1.6 1998/06/23 22:40:27 millert Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/param.h> @@ -66,7 +66,7 @@ setproctitle(fmt, va_alist) va_list ap; static char buf[MAX_PROCTITLE], *bufp = buf; - int used; + size_t used; #ifdef __STDC__ va_start(ap, fmt); @@ -75,6 +75,8 @@ setproctitle(fmt, va_alist) #endif if (fmt != NULL) { used = snprintf(buf, MAX_PROCTITLE, "%s: ", __progname); + if (used >= MAX_PROCTITLE) + used = MAX_PROCTITLE - 1; (void)vsnprintf(buf + used, MAX_PROCTITLE - used, fmt, ap); } else (void)snprintf(buf, MAX_PROCTITLE, "%s", __progname); diff --git a/libexec/telnetd/global.c b/libexec/telnetd/global.c index 11b2cd5ed0f..2d2d9a03a3f 100644 --- a/libexec/telnetd/global.c +++ b/libexec/telnetd/global.c @@ -1,4 +1,4 @@ -/* $OpenBSD: global.c,v 1.3 1998/03/12 04:53:11 art Exp $ */ +/* $OpenBSD: global.c,v 1.4 1998/06/23 22:40:29 millert Exp $ */ /* $NetBSD: global.c,v 1.6 1996/02/28 20:38:14 thorpej Exp $ */ /* @@ -39,7 +39,7 @@ static char sccsid[] = "@(#)global.c 8.1 (Berkeley) 6/4/93"; static char rcsid[] = "$NetBSD: global.c,v 1.6 1996/02/28 20:38:14 thorpej Exp $"; #else -static char rcsid[] = "$OpenBSD: global.c,v 1.3 1998/03/12 04:53:11 art Exp $"; +static char rcsid[] = "$OpenBSD: global.c,v 1.4 1998/06/23 22:40:29 millert Exp $"; #endif #endif /* not lint */ @@ -68,6 +68,8 @@ output_data (const char *format, ...) remaining, format, args); + if (ret >= remaining) + ret = remaining - 1; nfrontp += ret; va_end(args); return ret; diff --git a/sbin/restore/dirs.c b/sbin/restore/dirs.c index 7f6eec0ac6c..2218bfcf084 100644 --- a/sbin/restore/dirs.c +++ b/sbin/restore/dirs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dirs.c,v 1.15 1998/02/17 00:07:51 millert Exp $ */ +/* $OpenBSD: dirs.c,v 1.16 1998/06/23 22:40:30 millert Exp $ */ /* $NetBSD: dirs.c,v 1.26 1997/07/01 05:37:49 lukem Exp $ */ /* @@ -43,7 +43,7 @@ #if 0 static char sccsid[] = "@(#)dirs.c 8.5 (Berkeley) 8/31/94"; #else -static char rcsid[] = "$OpenBSD: dirs.c,v 1.15 1998/02/17 00:07:51 millert Exp $"; +static char rcsid[] = "$OpenBSD: dirs.c,v 1.16 1998/06/23 22:40:30 millert Exp $"; #endif #endif /* not lint */ @@ -257,6 +257,8 @@ treescan(pname, ino, todo) * skipping over "." and ".." */ namelen = snprintf(locname, sizeof(locname), "%s/", pname); + if (namelen >= sizeof(locname)) + namelen = sizeof(locname) - 1; rst_seekdir(dirp, itp->t_seekpt, itp->t_seekpt); dp = rst_readdir(dirp); /* "." */ if (dp != NULL && strcmp(dp->d_name, ".") == 0) diff --git a/sbin/restore/interactive.c b/sbin/restore/interactive.c index f37c0d6eccb..b0050e5185d 100644 --- a/sbin/restore/interactive.c +++ b/sbin/restore/interactive.c @@ -1,4 +1,4 @@ -/* $OpenBSD: interactive.c,v 1.6 1998/01/31 23:08:49 millert Exp $ */ +/* $OpenBSD: interactive.c,v 1.7 1998/06/23 22:40:31 millert Exp $ */ /* $NetBSD: interactive.c,v 1.10 1997/03/19 08:42:52 lukem Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)interactive.c 8.3 (Berkeley) 9/13/94"; #else -static char rcsid[] = "$OpenBSD: interactive.c,v 1.6 1998/01/31 23:08:49 millert Exp $"; +static char rcsid[] = "$OpenBSD: interactive.c,v 1.7 1998/06/23 22:40:31 millert Exp $"; #endif #endif /* not lint */ @@ -537,6 +537,8 @@ printlist(name, basename) entries = 0; listp = list; namelen = snprintf(locname, sizeof(locname), "%s/", name); + if (namelen >= sizeof(locname)) + namelen = sizeof(locname) - 1; while ((dp = rst_readdir(dirp))) { if (dp == NULL) break; diff --git a/usr.bin/netstat/atalk.c b/usr.bin/netstat/atalk.c index f6b33c45fb1..d57aa91b3bf 100644 --- a/usr.bin/netstat/atalk.c +++ b/usr.bin/netstat/atalk.c @@ -219,7 +219,7 @@ atalk_print2(sa, mask, what) const struct sockaddr *mask; int what; { - int n; + size_t n, l; static char buf[100]; struct sockaddr_at *sat1, *sat2; struct sockaddr_at thesockaddr; @@ -232,15 +232,24 @@ atalk_print2(sa, mask, what) thesockaddr.sat_addr.s_net = sat1->sat_addr.s_net & sat2->sat_addr.s_net; n = snprintf(buf, sizeof(buf), "%s", atalk_print(sa2, 1 | (what & 8))); + if (n >= sizeof(buf)) + n = sizeof(buf) - 1; if (sat2->sat_addr.s_net != 0xFFFF) { thesockaddr.sat_addr.s_net = sat1->sat_addr.s_net | ~sat2->sat_addr.s_net; - n += snprintf(buf + n, sizeof(buf) - n, + l = snprintf(buf + n, sizeof(buf) - n, "-%s", atalk_print(sa2, 1 | (what & 8))); + if (l >= sizeof(buf) - n) + l = sizeof(buf) - n - 1; + n += l; } - if (what & 2) - n += snprintf(buf + n, sizeof(buf) - n, ".%s", + if (what & 2) { + l = snprintf(buf + n, sizeof(buf) - n, ".%s", atalk_print(sa, what & (~1))); + if (l >= sizeof(buf) - n) + l = sizeof(buf) - n - 1; + n += l; + } return (buf); } diff --git a/usr.bin/netstat/route.c b/usr.bin/netstat/route.c index 950e9d4c111..ced59780a73 100644 --- a/usr.bin/netstat/route.c +++ b/usr.bin/netstat/route.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route.c,v 1.24 1998/05/18 19:03:29 deraadt Exp $ */ +/* $OpenBSD: route.c,v 1.25 1998/06/23 22:40:40 millert Exp $ */ /* $NetBSD: route.c,v 1.15 1996/05/07 02:55:06 thorpej Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "from: @(#)route.c 8.3 (Berkeley) 3/9/94"; #else -static char *rcsid = "$OpenBSD: route.c,v 1.24 1998/05/18 19:03:29 deraadt Exp $"; +static char *rcsid = "$OpenBSD: route.c,v 1.25 1998/06/23 22:40:40 millert Exp $"; #endif #endif /* not lint */ @@ -404,6 +404,7 @@ p_sockaddr(sa, mask, flags, width) { char workbuf[128], *cplim; register char *cp = workbuf; + size_t n; switch(sa->sa_family) { case AF_INET: @@ -444,9 +445,12 @@ p_sockaddr(sa, mask, flags, width) cplim = ""; for (i = 0; i < sdl->sdl_alen; i++, lla++) { - cp += snprintf(cp, + n = snprintf(cp, workbuf + sizeof (workbuf) - cp, "%s%x", cplim, *lla); + if (n >= workbuf + sizeof (workbuf) - cp) + n = workbuf + sizeof (workbuf) - cp - 1; + cp += n; cplim = ":"; } cp = workbuf; @@ -471,14 +475,24 @@ p_sockaddr(sa, mask, flags, width) slim = sa->sa_len + (u_char *) sa; cplim = cp + sizeof(workbuf) - 6; - cp += snprintf(cp, cplim - cp, "(%d)", sa->sa_family); + n = snprintf(cp, cplim - cp, "(%d)", sa->sa_family); + if (n >= cplim - cp) + n = cplim - cp - 1; + cp += n; while (s < slim && cp < cplim) { - cp += snprintf(cp, workbuf + sizeof (workbuf) - cp, + n = snprintf(cp, workbuf + sizeof (workbuf) - cp, " %02x", *s++); - if (s < slim) - cp += snprintf(cp, + if (n >= workbuf + sizeof (workbuf) - cp) + n = workbuf + sizeof (workbuf) - cp - 1; + cp += n; + if (s < slim) { + n = snprintf(cp, workbuf + sizeof (workbuf) - cp, "%02x", *s++); + if (n >= workbuf + sizeof (workbuf) - cp) + n = workbuf + sizeof (workbuf) - cp - 1; + cp += n; + } } cp = workbuf; } diff --git a/usr.bin/sed/main.c b/usr.bin/sed/main.c index f365409959f..757ef476cf8 100644 --- a/usr.bin/sed/main.c +++ b/usr.bin/sed/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.4 1997/01/15 23:43:12 millert Exp $ */ +/* $OpenBSD: main.c,v 1.5 1998/06/23 22:40:42 millert Exp $ */ /*- * Copyright (c) 1992 Diomidis Spinellis. @@ -45,7 +45,7 @@ static char copyright[] = #ifndef lint /* from: static char sccsid[] = "@(#)main.c 8.2 (Berkeley) 1/3/94"; */ -static char *rcsid = "$OpenBSD: main.c,v 1.4 1997/01/15 23:43:12 millert Exp $"; +static char *rcsid = "$OpenBSD: main.c,v 1.5 1998/06/23 22:40:42 millert Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -191,7 +191,7 @@ again: case CU_STRING: if ((snprintf(string_ident, sizeof(string_ident), "\"%s\"", script->s)) >= - sizeof(string_ident) - 1) + sizeof(string_ident)) (void)strcpy(string_ident + sizeof(string_ident) - 6, " ...\""); fname = string_ident; diff --git a/usr.bin/vi/cl/cl_term.c b/usr.bin/vi/cl/cl_term.c index 6edaffb0bf4..a86b9924b00 100644 --- a/usr.bin/vi/cl/cl_term.c +++ b/usr.bin/vi/cl/cl_term.c @@ -221,6 +221,8 @@ cl_pfmap(sp, stype, from, flen, to, tlen) nlen = snprintf(keyname, sizeof(keyname), "function key %d", atoi(from + 1)); + if (nlen >= sizeof(keyname)) + nlen = sizeof(keyname) - 1; return (seq_set(sp, keyname, nlen, p, strlen(p), to, tlen, stype, SEQ_NOOVERWRITE | SEQ_SCREEN)); } diff --git a/usr.bin/vi/common/api.c b/usr.bin/vi/common/api.c index 35d9f0c8f66..aac0ac627b3 100644 --- a/usr.bin/vi/common/api.c +++ b/usr.bin/vi/common/api.c @@ -488,14 +488,20 @@ api_opts_set(sp, name, str_value, num_value, bool_value) case OPT_1BOOL: GET_SPACE_RET(sp, bp, blen, 64); a.len = snprintf(bp, 64, "%s%s", bool_value ? "" : "no", name); + if (a.len > 63) + a.len = 63; break; case OPT_NUM: GET_SPACE_RET(sp, bp, blen, 64); a.len = snprintf(bp, 64, "%s=%lu", name, num_value); + if (a.len > 63) + a.len = 63; break; case OPT_STR: GET_SPACE_RET(sp, bp, blen, 1024); a.len = snprintf(bp, 1024, "%s=%s", name, str_value); + if (a.len > 63) + a.len = 63; break; } a.bp = bp; diff --git a/usr.bin/vi/common/exf.c b/usr.bin/vi/common/exf.c index 39c781a3f7d..574a16aab3b 100644 --- a/usr.bin/vi/common/exf.c +++ b/usr.bin/vi/common/exf.c @@ -482,6 +482,8 @@ file_spath(sp, frp, sbp, existsp) *p = '\0'; len = snprintf(path, sizeof(path), "%s/%s", t, name); + if (len >= sizeof(path)) + len = sizeof(path) - 1; *p = savech; if (!stat(path, sbp)) { found = 1; @@ -941,12 +943,16 @@ file_write(sp, fm, tm, name, flags) msgstr = msg_cat(sp, "256|%s: new file: %lu lines, %lu characters", NULL); len = snprintf(buf, sizeof(buf), msgstr, p, nlno, nch); + if (len >= sizeof(buf)) + len = sizeof(buf) - 1; break; case OLDFILE: msgstr = msg_cat(sp, LF_ISSET(FS_APPEND) ? "315|%s: appended: %lu lines, %lu characters" : "257|%s: %lu lines, %lu characters", NULL); len = snprintf(buf, sizeof(buf), msgstr, p, nlno, nch); + if (len >= sizeof(buf)) + len = sizeof(buf) - 1; break; default: abort(); diff --git a/usr.bin/vi/ex/ex_tag.c b/usr.bin/vi/ex/ex_tag.c index 63d80626a41..15aa58f4cc8 100644 --- a/usr.bin/vi/ex/ex_tag.c +++ b/usr.bin/vi/ex/ex_tag.c @@ -1181,7 +1181,6 @@ ctag_file(sp, tfp, name, dirp, dlenp) size_t *dlenp; { struct stat sb; - size_t len; char *p, buf[MAXPATHLEN]; /* @@ -1196,7 +1195,7 @@ ctag_file(sp, tfp, name, dirp, dlenp) if (name[0] != '/' && stat(name, &sb) && (p = strrchr(tfp->name, '/')) != NULL) { *p = '\0'; - len = snprintf(buf, sizeof(buf), "%s/%s", tfp->name, name); + (void)snprintf(buf, sizeof(buf), "%s/%s", tfp->name, name); if (stat(buf, &sb) == 0) { *dirp = tfp->name; *dlenp = strlen(*dirp); diff --git a/usr.bin/vi/ex/ex_visual.c b/usr.bin/vi/ex/ex_visual.c index 82e503d4465..c181f7709f4 100644 --- a/usr.bin/vi/ex/ex_visual.c +++ b/usr.bin/vi/ex/ex_visual.c @@ -84,6 +84,8 @@ ex_visual(sp, cmdp) "%luz%c%lu", sp->lno, pos, cmdp->count); else len = snprintf(buf, sizeof(buf), "%luz%c", sp->lno, pos); + if (len >= sizeof(buf)) + len = sizeof(buf) - 1; (void)v_event_push(sp, NULL, buf, len, CH_NOMAP | CH_QUOTED); /* diff --git a/usr.bin/vi/vi/v_at.c b/usr.bin/vi/vi/v_at.c index d266f275d98..7231bb1b674 100644 --- a/usr.bin/vi/vi/v_at.c +++ b/usr.bin/vi/vi/v_at.c @@ -102,6 +102,8 @@ v_at(sp, vp) */ if (F_ISSET(vp, VC_C1SET)) { len = snprintf(nbuf, sizeof(nbuf), "%lu", vp->count); + if (len >= sizeof(nbuf)) + len = sizeof(nbuf) - 1; if (v_event_push(sp, NULL, nbuf, len, 0)) return (1); } diff --git a/usr.bin/vi/vi/v_increment.c b/usr.bin/vi/vi/v_increment.c index 45e763fa5bd..370143187c6 100644 --- a/usr.bin/vi/vi/v_increment.c +++ b/usr.bin/vi/vi/v_increment.c @@ -204,6 +204,8 @@ nonum: msgq(sp, M_ERR, "181|Cursor not in a number"); if (lval == 0 && ntype == fmt[SDEC]) ntype = fmt[DEC]; nlen = snprintf(nbuf, sizeof(nbuf), ntype, lval); + if (nlen >= sizeof(nbuf)) + nlen = sizeof(nbuf) - 1; } else { if ((nret = nget_uslong(&ulval, t, NULL, base)) != NUM_OK) goto err; @@ -226,6 +228,8 @@ nonum: msgq(sp, M_ERR, "181|Cursor not in a number"); wlen -= 2; nlen = snprintf(nbuf, sizeof(nbuf), ntype, wlen, ulval); + if (nlen >= sizeof(nbuf)) + nlen = sizeof(nbuf) - 1; } /* Build the new line. */ diff --git a/usr.bin/vi/vi/v_search.c b/usr.bin/vi/vi/v_search.c index 4f7a2671ab8..6851a93fa5b 100644 --- a/usr.bin/vi/vi/v_search.c +++ b/usr.bin/vi/vi/v_search.c @@ -255,6 +255,8 @@ v_exaddr(sp, vp, dir) /* Push line number so get correct z display. */ tlen = snprintf(buf, sizeof(buf), "%lu", (u_long)vp->m_stop.lno); + if (tlen >= sizeof(buf)) + tlen = sizeof(buf) - 1; if (v_event_push(sp, NULL, buf, tlen, CH_NOMAP | CH_QUOTED)) return (1); @@ -336,6 +338,8 @@ v_searchw(sp, vp) len = VIP(sp)->klen + sizeof(RE_WSTART) + sizeof(RE_WSTOP); GET_SPACE_RET(sp, bp, blen, len); len = snprintf(bp, blen, "%s%s%s", RE_WSTART, VIP(sp)->keyw, RE_WSTOP); + if (len >= blen) + len = blen - 1; rval = v_search(sp, vp, bp, len, SEARCH_SET, FORWARD); diff --git a/usr.bin/vi/vi/vs_line.c b/usr.bin/vi/vi/vs_line.c index b439de925ce..a8a65c0d3ca 100644 --- a/usr.bin/vi/vi/vs_line.c +++ b/usr.bin/vi/vi/vs_line.c @@ -140,6 +140,8 @@ vs_line(sp, smp, yp, xp) if ((!dne || smp->lno == 1) && skip_cols == 0) { nlen = snprintf(cbuf, sizeof(cbuf), O_NUMBER_FMT, smp->lno); + if (nlen >= sizeof(cbuf)) + nlen = sizeof(cbuf) - 1; (void)gp->scr_addstr(sp, cbuf, nlen); } } @@ -507,6 +509,8 @@ vs_number(sp) (void)gp->scr_move(sp, smp - HMAP, 0); len = snprintf(nbuf, sizeof(nbuf), O_NUMBER_FMT, smp->lno); + if (len >= sizeof(nbuf)) + len = sizeof(nbuf) - 1; (void)gp->scr_addstr(sp, nbuf, len); } (void)gp->scr_move(sp, oldy, oldx); 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; |