summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/snprintf.c
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1998-01-01 20:15:58 +0000
committerache <ache@FreeBSD.org>1998-01-01 20:15:58 +0000
commit1ecfa643a967dee7271e7b64d29613493dfa1be4 (patch)
treeb24571fae04d8bc43296039e8aa3f2aecddad160 /lib/libc/stdio/snprintf.c
parent4da8ac54d4f34432f621e6af77663ae9ec429776 (diff)
downloadFreeBSD-src-1ecfa643a967dee7271e7b64d29613493dfa1be4.zip
FreeBSD-src-1ecfa643a967dee7271e7b64d29613493dfa1be4.tar.gz
1. EOF was returned when the buffer size was larger than INT_MAX. This
case has very little to do with the output size being larger than INT_MAX. 2. The new #include of <limits.h> was disordered. 3. The new declaration of `on' was disordered (integer types go together). 4. Testing an unsigned value for > 0 was fishy. Submitted by: bde
Diffstat (limited to 'lib/libc/stdio/snprintf.c')
-rw-r--r--lib/libc/stdio/snprintf.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/libc/stdio/snprintf.c b/lib/libc/stdio/snprintf.c
index aa70bb2..a4c04d9 100644
--- a/lib/libc/stdio/snprintf.c
+++ b/lib/libc/stdio/snprintf.c
@@ -39,16 +39,16 @@
static char sccsid[] = "@(#)snprintf.c 8.1 (Berkeley) 6/4/93";
#endif
static const char rcsid[] =
- "$Id: snprintf.c,v 1.9 1997/12/24 23:02:40 ache Exp $";
+ "$Id: snprintf.c,v 1.10 1997/12/24 23:54:13 ache Exp $";
#endif /* LIBC_SCCS and not lint */
+#include <limits.h>
#include <stdio.h>
#if __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#endif
-#include <limits.h>
#if __STDC__
int
@@ -62,16 +62,16 @@ snprintf(str, n, fmt, va_alist)
va_dcl
#endif
{
+ size_t on;
int ret;
va_list ap;
FILE f;
- size_t on;
on = n;
- if (n > 0)
+ if (n != 0)
n--;
if (n > INT_MAX)
- return (EOF);
+ n = INT_MAX;
#if __STDC__
va_start(ap, fmt);
#else
OpenPOWER on IntegriCloud