Module Name:    src
Committed By:   martin
Date:           Tue Sep 30 18:21:40 UTC 2014

Modified Files:
        src/lib/libc/stdio [netbsd-7]: printf.3 vsnprintf.c vsnprintf_ss.c

Log Message:
Pull up following revision(s) (requested by christos in ticket #122):
        lib/libc/stdio/printf.3: revision 1.64
        lib/libc/stdio/vsnprintf.c: revision 1.28
        lib/libc/stdio/vsnprintf_ss.c: revision 1.13
Return EOVERFLOW like FreeBSD does if the buffer size exceeds INT_MAX
(well FreeBSD documents INT_MAX + 1, but in the code it is INT_MAX).


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.63.6.1 src/lib/libc/stdio/printf.3
cvs rdiff -u -r1.27 -r1.27.6.1 src/lib/libc/stdio/vsnprintf.c
cvs rdiff -u -r1.12 -r1.12.10.1 src/lib/libc/stdio/vsnprintf_ss.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/stdio/printf.3
diff -u src/lib/libc/stdio/printf.3:1.63 src/lib/libc/stdio/printf.3:1.63.6.1
--- src/lib/libc/stdio/printf.3:1.63	Sat May  4 19:17:38 2013
+++ src/lib/libc/stdio/printf.3	Tue Sep 30 18:21:40 2014
@@ -1,4 +1,4 @@
-.\"	$NetBSD: printf.3,v 1.63 2013/05/04 19:17:38 wiz Exp $
+.\"	$NetBSD: printf.3,v 1.63.6.1 2014/09/30 18:21:40 martin Exp $
 .\"
 .\" Copyright (c) 1990, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -33,7 +33,7 @@
 .\"
 .\"     @(#)printf.3	8.1 (Berkeley) 6/4/93
 .\"
-.Dd May 4, 2013
+.Dd September 29, 2014
 .Dt PRINTF 3
 .Os
 .Sh NAME
@@ -799,6 +799,13 @@ family of functions may fail if:
 An invalid wide-character code was encountered.
 .It Bq Er ENOMEM
 Insufficient storage space is available.
+.It Bq Er EOVERFLOW
+The
+.Fa size
+argument exceeds
+.Dv INT_MAX ,
+or the return value would be too large to be represented by an
+.Vt int .
 .El
 .Sh SEE ALSO
 .Xr printf 1 ,

Index: src/lib/libc/stdio/vsnprintf.c
diff -u src/lib/libc/stdio/vsnprintf.c:1.27 src/lib/libc/stdio/vsnprintf.c:1.27.6.1
--- src/lib/libc/stdio/vsnprintf.c:1.27	Fri May 17 12:55:57 2013
+++ src/lib/libc/stdio/vsnprintf.c	Tue Sep 30 18:21:40 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: vsnprintf.c,v 1.27 2013/05/17 12:55:57 joerg Exp $	*/
+/*	$NetBSD: vsnprintf.c,v 1.27.6.1 2014/09/30 18:21:40 martin Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)vsnprintf.c	8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: vsnprintf.c,v 1.27 2013/05/17 12:55:57 joerg Exp $");
+__RCSID("$NetBSD: vsnprintf.c,v 1.27.6.1 2014/09/30 18:21:40 martin Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -76,8 +76,8 @@ vsnprintf_l(char *str, size_t n, locale_
 	_DIAGASSERT(n == 0 || str != NULL);
 	_DIAGASSERT(fmt != NULL);
 
-	if ((int)n < 0) {
-		errno = EINVAL;
+	if (n > INT_MAX) {
+		errno = EOVERFLOW;
 		return -1;
 	}
 

Index: src/lib/libc/stdio/vsnprintf_ss.c
diff -u src/lib/libc/stdio/vsnprintf_ss.c:1.12 src/lib/libc/stdio/vsnprintf_ss.c:1.12.10.1
--- src/lib/libc/stdio/vsnprintf_ss.c:1.12	Thu Mar 15 18:22:31 2012
+++ src/lib/libc/stdio/vsnprintf_ss.c	Tue Sep 30 18:21:40 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: vsnprintf_ss.c,v 1.12 2012/03/15 18:22:31 christos Exp $	*/
+/*	$NetBSD: vsnprintf_ss.c,v 1.12.10.1 2014/09/30 18:21:40 martin Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)vsnprintf.c	8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: vsnprintf_ss.c,v 1.12 2012/03/15 18:22:31 christos Exp $");
+__RCSID("$NetBSD: vsnprintf_ss.c,v 1.12.10.1 2014/09/30 18:21:40 martin Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -144,8 +144,8 @@ vsnprintf_ss(char *sbuf, size_t slen, co
 	_DIAGASSERT(slen == 0 || sbuf != NULL);
 	_DIAGASSERT(fmt0 != NULL);
 
-	if ((int)slen < 0) {
-		errno = EINVAL;
+	if (slen > INT_MAX) {
+		errno = EOVERFLOW;
 		return -1;
 	}
 

Reply via email to