httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Re: rprintf()
Date Fri, 17 May 1996 18:06:33 GMT
> If someone else has grabbed the horns on getting this working in
> an acceptable way, please stop me.  I'm getting tired of doing
> type conversions and will probably tackle this in the next few
> hours.

Without vsnprintf() it is extremely tricky to build a safe varargs
printf function.  If you look in the PHP/FI distribution in the echo.c
file you will find a function called FormatCheck():

 * FormatCheck - Scan through format string until first formatter is
 * found and return the type, or -1 on an error.  If no type-checking
 * needs to be done it returns 1, or if no formatting sequences were found,
 * it returns 0.
 * It also advances the format pointer to one past the found formatting
 * sequence and returns the skipped characters along with the formatting
 * sequence itself in *beg and *fmt respectively.
int FormatCheck(char **format, char **beg, char **fmt) {

If you loops through your varargs and call this function for each one,
thereby advancing your way through the format string, you can send each
individual component.  There is still the issue of overflowing buffers
to worry about though.  ie.  "%1000s"


View raw message