diff options
| author | Andrey A. Chernov <ache@FreeBSD.org> | 1997-12-24 20:24:08 +0000 | 
|---|---|---|
| committer | Andrey A. Chernov <ache@FreeBSD.org> | 1997-12-24 20:24:08 +0000 | 
| commit | e0b123f6d0eca4574a0d93f3e4f1f0d2aa93b4c4 (patch) | |
| tree | 18bf7a3395c17f5ccd21a7d029ee38e61fdc9be0 /lib/libc/stdio/snprintf.c | |
| parent | d83662583cee68a147e1073a5546fbf64886fcb9 (diff) | |
Notes
Diffstat (limited to 'lib/libc/stdio/snprintf.c')
| -rw-r--r-- | lib/libc/stdio/snprintf.c | 10 | 
1 files changed, 5 insertions, 5 deletions
| diff --git a/lib/libc/stdio/snprintf.c b/lib/libc/stdio/snprintf.c index 8a7584c0bec5..bfcf72c9de6a 100644 --- a/lib/libc/stdio/snprintf.c +++ b/lib/libc/stdio/snprintf.c @@ -39,7 +39,7 @@  static char sccsid[] = "@(#)snprintf.c	8.1 (Berkeley) 6/4/93";  #endif  static const char rcsid[] = -		"$Id: snprintf.c,v 1.6 1997/12/24 12:31:31 ache Exp $"; +		"$Id: snprintf.c,v 1.7 1997/12/24 14:32:39 ache Exp $";  #endif /* LIBC_SCCS and not lint */  #include <stdio.h> @@ -48,6 +48,7 @@ static const char rcsid[] =  #else  #include <varargs.h>  #endif +#include <limits.h>  #if __STDC__  int @@ -65,9 +66,10 @@ snprintf(str, n, fmt, va_alist)  	va_list ap;  	FILE f; -	if ((int)n < 1) +	if (n == 0) +		return (0); +	if (--n > INT_MAX)  		return (EOF); -	n--;  #if __STDC__  	va_start(ap, fmt);  #else @@ -80,7 +82,5 @@ snprintf(str, n, fmt, va_alist)  	ret = vfprintf(&f, fmt, ap);  	*f._p = 0;  	va_end(ap); -	if (ret == EOF) -		return (ret);  	return (ret > (int)n ? n : ret);  } | 
