diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1998-06-23 22:40:56 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1998-06-23 22:40:56 +0000 |
commit | 30cb72a00b8cc59895c391cad0f8e31611611ec4 (patch) | |
tree | 3e2f67dd80af3489363cf0596b740c6533994e40 /lib/libc | |
parent | 325437057bbda9490b174c8fc6dc8f0e14a8f145 (diff) |
Fix snprintf return value usage.
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/gen/getbsize.c | 4 | ||||
-rw-r--r-- | lib/libc/gen/setproctitle.c | 6 |
2 files changed, 7 insertions, 3 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); |