Do not use __builtin_alloca in puts (could overflow the stack for large strings)
This commit is contained in:
parent
34aa953dbc
commit
9420484c9b
@ -49,10 +49,8 @@ extern "C"
|
||||
}
|
||||
int puts(const char* s)
|
||||
{
|
||||
size_t len = strlen(s);
|
||||
char* output = (char*)__builtin_alloca(len + 1);
|
||||
memcpy(output, s, len);
|
||||
output[len] = '\n';
|
||||
return syscall(SYS_write, output, len + 1);
|
||||
long nwritten = syscall(SYS_write, s, strlen(s));
|
||||
nwritten += syscall(SYS_write, "\n", 1);
|
||||
return nwritten;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user