mirror of https://github.com/ARMmbed/mbed-os.git
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
parent
5687a86731
commit
a2853d2aa4
|
@ -47,13 +47,6 @@ int RawSerial::puts(const char *str) {
|
||||||
int RawSerial::printf(const char *format, ...) {
|
int RawSerial::printf(const char *format, ...) {
|
||||||
std::va_list arg;
|
std::va_list arg;
|
||||||
va_start(arg, format);
|
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);
|
int len = vsnprintf(NULL, 0, format, arg);
|
||||||
if (len < STRING_STACK_LIMIT) {
|
if (len < STRING_STACK_LIMIT) {
|
||||||
char temp[STRING_STACK_LIMIT];
|
char temp[STRING_STACK_LIMIT];
|
||||||
|
@ -65,7 +58,6 @@ int RawSerial::printf(const char *format, ...) {
|
||||||
puts(temp);
|
puts(temp);
|
||||||
delete[] temp;
|
delete[] temp;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
va_end(arg);
|
va_end(arg);
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue