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


The specification for printf is that width parameters have type 'int' when
they are passed in for "%*d" and the like.  So it's clearly proper to use
that in va_arg, and makes sense to use it for storage.  In that context,
negative values have a meaning, so INT_MAX is the true maximum.  Hence I
think it makes sense to diagnose literals in the format string as invalid
when above INT_MAX, and do so early.  We have an early check there already.
But it's checking for (size_t) -1 / sizeof (CHAR_T) - 32, which is far
above INT_MAX even for 32-bit size_t (though not so in w*printf where
CHAR_T is wchar_t).  Would there be a problem with just making that check
also refuse anything above INT_MAX?

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.


Thanks,
Roland


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