Hi, Unfortunately it seems that Keil brings only the standard version of sprintf which ist not safe against Buffer Overflows. So I am looking for a safe version (like snprintf from libsafe). Can anybody give me a hint where to find sources or even better did anybody already write a snprintf and is willing to share his code with me? Best regards, Marcus
"Can anybody give me a hint where to find sources ..." Seriously, Google found it in a jiffy.
BSD-licensed Unix is always one place to look for library code: http://www.freebsd.org/cgi/cvsweb.cgi/src/lib/libc/
"Seriously, Google found it in a jiffy" Another very helpful answer... Board would take half the size... Anyway, I know Google finds a lot of stuff, and I also already looked through the sources of my Linux Implementation. But most of that code is plattform dependant using other extensions of the libc. My Intention was to spare some time for porting Code in case others already did that. Obviously it is not the case so just close this thread. @Drew: Thanks for the hint. But I now create my own stdio-lib.
You're joking, right? Google for "snprintf.c" "Anyway, I know Google finds a lot of stuff ... But most of that code is plattform dependant using other extensions of the libc."
ok ok, you are right and there are independant implementations ^^. What I meant is that they simply contain lots of stuff for various other plattforms I do not need. I know its not the problem, most of the code will not be used if you do not define what you don't need, but I would have to clean it up anyway. And I also do not need most of the supported specifiers. %s, c, d, u are sufficient. No long, long long, precision or whatever. I just needed a small and simple code saving implementation.