Module Name:    src
Committed By:   msaitoh
Date:           Mon Nov  3 21:22:28 UTC 2014

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

Log Message:
Pull up following revision(s) (requested by christos in ticket #1161):
        lib/libc/stdio/printf.3: revision 1.64 via patch
        lib/libc/stdio/vsnprintf.c: revision 1.28 via patch
        lib/libc/stdio/vsnprintf_ss.c: revision 1.13 via patch
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).
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.58 -r1.58.8.1 src/lib/libc/stdio/printf.3
cvs rdiff -u -r1.23 -r1.23.4.1 src/lib/libc/stdio/vsnprintf.c
cvs rdiff -u -r1.10 -r1.10.4.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.58 src/lib/libc/stdio/printf.3:1.58.8.1
--- src/lib/libc/stdio/printf.3:1.58	Sun Dec 26 12:39:54 2010
+++ src/lib/libc/stdio/printf.3	Mon Nov  3 21:22:28 2014
@@ -1,4 +1,4 @@
-.\"	$NetBSD: printf.3,v 1.58 2010/12/26 12:39:54 jnemeth Exp $
+.\"	$NetBSD: printf.3,v 1.58.8.1 2014/11/03 21:22:28 msaitoh 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 December 26, 2010
+.Dd September 29, 2014
 .Dt PRINTF 3
 .Os
 .Sh NAME
@@ -793,6 +793,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.23 src/lib/libc/stdio/vsnprintf.c:1.23.4.1
--- src/lib/libc/stdio/vsnprintf.c:1.23	Sun Jul 17 20:54:34 2011
+++ src/lib/libc/stdio/vsnprintf.c	Mon Nov  3 21:22:28 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: vsnprintf.c,v 1.23 2011/07/17 20:54:34 joerg Exp $	*/
+/*	$NetBSD: vsnprintf.c,v 1.23.4.1 2014/11/03 21:22:28 msaitoh 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.23 2011/07/17 20:54:34 joerg Exp $");
+__RCSID("$NetBSD: vsnprintf.c,v 1.23.4.1 2014/11/03 21:22:28 msaitoh Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -69,9 +69,9 @@ vsnprintf(char *str, size_t n, const cha
 	_DIAGASSERT(n == 0 || str != NULL);
 	_DIAGASSERT(fmt != NULL);
 
-	if ((int)n < 0) {
-		errno = EINVAL;
-		return (-1);
+	if (n > INT_MAX) {
+		errno = EOVERFLOW;
+		return -1;
 	}
 
 	_FILEEXT_SETUP(&f, &fext);

Index: src/lib/libc/stdio/vsnprintf_ss.c
diff -u src/lib/libc/stdio/vsnprintf_ss.c:1.10 src/lib/libc/stdio/vsnprintf_ss.c:1.10.4.1
--- src/lib/libc/stdio/vsnprintf_ss.c:1.10	Sun Jul 17 20:54:34 2011
+++ src/lib/libc/stdio/vsnprintf_ss.c	Mon Nov  3 21:22:28 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: vsnprintf_ss.c,v 1.10 2011/07/17 20:54:34 joerg Exp $	*/
+/*	$NetBSD: vsnprintf_ss.c,v 1.10.4.1 2014/11/03 21:22:28 msaitoh 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.10 2011/07/17 20:54:34 joerg Exp $");
+__RCSID("$NetBSD: vsnprintf_ss.c,v 1.10.4.1 2014/11/03 21:22:28 msaitoh Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -143,9 +143,9 @@ vsnprintf_ss(char *sbuf, size_t slen, co
 	_DIAGASSERT(slen == 0 || sbuf != NULL);
 	_DIAGASSERT(fmt0 != NULL);
 
-	if ((int)slen < 0) {
-		errno = EINVAL;
-		return (-1);
+	if (slen > INT_MAX) {
+		errno = EOVERFLOW;
+		return -1;
 	}
 
 	tailp = sbuf + slen;

Reply via email to