From 31041a4c8166889360cf76d3796547621f3dd5a6 Mon Sep 17 00:00:00 2001 From: Moritz Jodeit Date: Tue, 8 Mar 2005 15:38:47 +0000 Subject: handle snprintf() returning -1. ok cloder@ henning@ hshoexer@ --- lib/libc/gen/setproctitle.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/libc/gen') 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 @@ -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); -- cgit v1.2.3