summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
authormoritz <moritz@openbsd.org>2005-03-08 15:38:46 +0000
committermoritz <moritz@openbsd.org>2005-03-08 15:38:46 +0000
commit939b4bb171309e3351e6e7c00ee6fd6d3d498c3e (patch)
tree8bef2dfa90278f25d417f40a0625950cd5f01348 /lib/libc
parentSome more real-life regression cases. (diff)
downloadwireguard-openbsd-939b4bb171309e3351e6e7c00ee6fd6d3d498c3e.tar.xz
wireguard-openbsd-939b4bb171309e3351e6e7c00ee6fd6d3d498c3e.zip
handle snprintf() returning -1.
ok cloder@ henning@ hshoexer@
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/gen/setproctitle.c6
-rw-r--r--lib/libc/gen/syslog.c4
2 files changed, 7 insertions, 3 deletions
diff --git a/lib/libc/gen/setproctitle.c b/lib/libc/gen/setproctitle.c
index fd23dbdab3e..21eddd13084 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.9 2002/02/19 19:39:36 millert Exp $";
+static char rcsid[] = "$OpenBSD: setproctitle.c,v 1.10 2005/03/08 15:38:46 moritz Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
@@ -54,13 +54,15 @@ setproctitle(const char *fmt, ...)
va_list ap;
static char buf[MAX_PROCTITLE], *bufp = buf;
- size_t used;
+ int used;
va_start(ap, fmt);
if (fmt != NULL) {
used = snprintf(buf, MAX_PROCTITLE, "%s: ", __progname);
if (used >= MAX_PROCTITLE)
used = MAX_PROCTITLE - 1;
+ else if (used < 0)
+ used = 0;
(void)vsnprintf(buf + used, MAX_PROCTITLE - used, fmt, ap);
} else
(void)snprintf(buf, MAX_PROCTITLE, "%s", __progname);
diff --git a/lib/libc/gen/syslog.c b/lib/libc/gen/syslog.c
index 890209055f0..fdd10b76b9d 100644
--- a/lib/libc/gen/syslog.c
+++ b/lib/libc/gen/syslog.c
@@ -28,7 +28,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: syslog.c,v 1.26 2004/05/18 02:05:52 jfb Exp $";
+static char rcsid[] = "$OpenBSD: syslog.c,v 1.27 2005/03/08 15:41:03 moritz Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@@ -204,6 +204,8 @@ vsyslog_r(int pri, struct syslog_data *data, const char *fmt, va_list ap)
prlen = snprintf(t, fmt_left, "Error %d",
saved_errno);
}
+ if (prlen < 0)
+ prlen = 0;
if (prlen >= fmt_left)
prlen = fmt_left - 1;
t += prlen;