summaryrefslogtreecommitdiff
path: root/lib/libc/stdio/vsnprintf.c
diff options
context:
space:
mode:
authorAndrey A. Chernov <ache@FreeBSD.org>1997-12-24 20:24:08 +0000
committerAndrey A. Chernov <ache@FreeBSD.org>1997-12-24 20:24:08 +0000
commite0b123f6d0eca4574a0d93f3e4f1f0d2aa93b4c4 (patch)
tree18bf7a3395c17f5ccd21a7d029ee38e61fdc9be0 /lib/libc/stdio/vsnprintf.c
parentd83662583cee68a147e1073a5546fbf64886fcb9 (diff)
Notes
Diffstat (limited to 'lib/libc/stdio/vsnprintf.c')
-rw-r--r--lib/libc/stdio/vsnprintf.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/libc/stdio/vsnprintf.c b/lib/libc/stdio/vsnprintf.c
index 8d824fe594b8..738dd212f318 100644
--- a/lib/libc/stdio/vsnprintf.c
+++ b/lib/libc/stdio/vsnprintf.c
@@ -39,10 +39,11 @@
static char sccsid[] = "@(#)vsnprintf.c 8.1 (Berkeley) 6/4/93";
#endif
static const char rcsid[] =
- "$Id: vsnprintf.c,v 1.6 1997/12/24 12:31:32 ache Exp $";
+ "$Id: vsnprintf.c,v 1.7 1997/12/24 14:32:40 ache Exp $";
#endif /* LIBC_SCCS and not lint */
#include <stdio.h>
+#include <limits.h>
int
vsnprintf(str, n, fmt, ap)
@@ -54,16 +55,15 @@ vsnprintf(str, n, fmt, ap)
int ret;
FILE f;
- if ((int)n < 1)
+ if (n == 0)
+ return (0);
+ if (--n > INT_MAX)
return (EOF);
- n--;
f._file = -1;
f._flags = __SWR | __SSTR;
f._bf._base = f._p = (unsigned char *)str;
f._bf._size = f._w = n;
ret = vfprintf(&f, fmt, ap);
*f._p = 0;
- if (ret == EOF)
- return (ret);
return (ret > (int)n ? n : ret);
}