[Patch, Newlib-nano]Improve printf to support non nul-terminated string
Sat Nov 1 03:16:00 GMT 2014
When use printf to print string that isn't nul-terminated like below:
printf("%.*s", sizeof(cp), moo);
current printf implementation in newlib-nano has a subtle bug that is the
call to strlen(cp). Suppose all 16 elements in cp are non-nul characters and
the storage next to cp is filled with value 0xFF (which is quite common for
flash of an embedded device), the strlen function will travel the memory
until trigger an error.
The Newlib implementation already realized this issue. The attached patch
intends to reuse Newlib implementation here for Newlib-nano to avoid such
2014-11-01 Terry Guo <email@example.com>
* libc/stdio/nano-vfprintf_i.c (_printf_i): Use Newlib approach to
handle string that might be not nul-terminated.
* testsuite/newlib.stdio/nulprintf.c: New test.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
More information about the Newlib