> Do we have any facilities (in C) for sprintf'ing the strings that may
> have NULL byte inside? For example, if name is "foo\0bar", and name_len
> is 7,
>
> sprintf(buf, "name: %*s", name_len, name);
>
> Does not give the correct result - stops at the first null byte.
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.
-Rasmus
--
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]