This is the mail archive of the newlib@sourceware.org mailing list for the newlib 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] |
Hi there, When use printf to print string that isn't nul-terminated like below: char cp[16]; 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 issue. BR, Terry 2014-11-01 Terry Guo <terry.guo@arm.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.
Attachment:
nano-non-nul-terminated-v3.txt
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |