This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
RE: 64-bit snprintf/vsnprintf overflow condition
- From: "Howland Craig D (Craig)" <howland at LGSInnovations dot com>
- To: "David A. Ramos" <daramos at stanford dot edu>, <newlib at sourceware dot org>
- Date: Fri, 29 Oct 2010 14:16:49 -0400
- Subject: RE: 64-bit snprintf/vsnprintf overflow condition
- References: <A9098236-C220-4893-B48C-218B1A47B893@stanford.edu>
INT_MAX is the behavior required by POSIX. See
http://www.opengroup.org/onlinepubs/9699919799/functions/fprintf.html
under the ERRORS section where EOVERFLOW is described.
Craig
-----Original Message-----
From: newlib-owner@sourceware.org [mailto:newlib-owner@sourceware.org]
On Behalf Of David A. Ramos
Sent: Friday, October 29, 2010 2:04 PM
To: newlib@sourceware.org
Subject: 64-bit snprintf/vsnprintf overflow condition
Hi,
It looks like the overflow condition in vsnprintf/snprintf is
unnecessarily restrictive for 64-bit architectures.
from libc/stdio/snprintf.c:
52 if (size > INT_MAX)
53 {
54 ptr->_errno = EOVERFLOW;
55 return EOF;
56 }
I believe it should use SIZE_MAX, rather than INT_MAX.
-David