This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: vfprintf typing problem


> From: Roland McGrath <roland@hack.frob.com>
> Date: Wed, 28 Mar 2012 15:25:24 -0700 (PDT)
> 
> > In the C standard (C99 and C11), I don't see anything that says anything
> > one way or another about the valid range of field width specifiers when
> > they appear directly in the format string.
> 
> See the comments in the glibc bug #5424 fixed by bug22.c, it
> references:
> 
> http://www.opengroup.org/platform/resolutions/bwg98-006.html
> 
> and also recent POSIX drafts.

Ok, that is rather indirect but seems to say that any situation in which
the total output requested would exceed INT_MAX chars should be diagnosed
with EOVERFLOW.  At least for snprintf, anyway.  We don't really seem to
diagnose that case as such.  Instead we have various checks that individual
pieces of the format aren't going to overflow size_t, and those are
diagnosed with ERANGE.  And the standard still doesn't really say anything
about fprintf, only snprintf.  It seems to be quite a mess.


Thanks,
Roland


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]