On Wed, 25 Apr 2001, Rasmus Lerdorf wrote:
> Don't think so.  And it also doesn't work if the format string contains a
> null byte because the parsing loop does:
> 
>    while (format[inpos]) { ...
> 
> I don't see any reason to not change this to loop over
> (*args[0])->value.str.len instead here.
> 
> As for the %*s issue.  We are passing in the length of the string arg in
> the call:
> 
>         php_sprintf_appendstring(&result, &outpos, &size,
>                                  (*args[argnum])->value.str.val,
>                                  width, precision, padding,
>                                  alignment,
>                                  (*args[argnum])->value.str.len,
>                                  0, expprec);
> 
> So we have the info.  In php_sprintf_appendstring() the replacement is
> done using:
> 
>       strncpy(&(*buffer)[*pos], add, MIN(max_width, len)+1);
> 
> Looks like simply changing this to a memcpy() call will fix this.  Again,
> I don't see any reason not to make this change.  PHP is supposed to be
> 8-bit clean and I think this should extend to the printf functions as
> well.

That's fine, but I'm not talking about userland sprintf(), but rather
using C library sprintf() call from inside one of my extension
functions. If glibc sprintf() doesn't handle NULL bytes, do we have a
replacement for it in PHP aside from php_formatted_print() which expects
to receive its arguments from a script?

-Andrei

When we eliminate the impossible, whatever remains,
however improbable, must be true. -- Sherlock Holmes

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to