summaryrefslogtreecommitdiff
path: root/lib/libc/gen/getbsize.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2001-08-18 22:56:23 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2001-08-18 22:56:23 +0000
commitc2daa7fd0984e62fe491ed5f9bbe2ae36008d266 (patch)
treecddaa91be55b85140d21394af625659ae698ab22 /lib/libc/gen/getbsize.c
parent6213d50bba5dce8b587c5197d22fc0b311b0b5df (diff)
deal with -1 from snprintf, if it ever happens
Diffstat (limited to 'lib/libc/gen/getbsize.c')
-rw-r--r--lib/libc/gen/getbsize.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/libc/gen/getbsize.c b/lib/libc/gen/getbsize.c
index 9ecff68119c..9aae0bc636e 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.6 1998/06/23 22:40:25 millert Exp $";
+static char rcsid[] = "$OpenBSD: getbsize.c,v 1.7 2001/08/18 22:56:22 deraadt Exp $";
#endif /* not lint */
#include <err.h>
@@ -101,7 +101,9 @@ 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))
+ if (*headerlenp < 0)
+ *headerlenp = 0;
+ else if (*headerlenp >= sizeof(header))
*headerlenp = sizeof(header) - 1;
*blocksizep = blocksize;
return (header);