Revert "Fixed crash issue in RawSerial::printf for uARM"

This reverts commit d05b7f51d8.

I am reverting this commit because:

- it uses alloca(), which is a dangerous function
- it uses vsprintf instead of vsnprintf, which can lead to a stack overflow.

Until we find a better solution, this might do more bad than good, so I am reverting it.
pull/490/head^2
Bogdan Marinescu 2014-09-12 10:43:47 +01:00
parent 5687a86731
commit a2853d2aa4
1 changed files with 0 additions and 8 deletions

View File

@ -47,13 +47,6 @@ int RawSerial::puts(const char *str) {
int RawSerial::printf(const char *format, ...) {
std::va_list arg;
va_start(arg, format);
#if defined(__MICROLIB) && defined(__ARMCC_VERSION) // with microlib and ARM compiler
char *temp;
temp = (char*)alloca(STRING_STACK_LIMIT);
vsprintf(temp, format, arg);
puts(temp);
int len = strlen(temp);
#else
int len = vsnprintf(NULL, 0, format, arg);
if (len < STRING_STACK_LIMIT) {
char temp[STRING_STACK_LIMIT];
@ -65,7 +58,6 @@ int RawSerial::printf(const char *format, ...) {
puts(temp);
delete[] temp;
}
#endif
va_end(arg);
return len;
}