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)
|
int puts(const char* s)
|
||||||
{
|
{
|
||||||
size_t len = strlen(s);
|
long nwritten = syscall(SYS_write, s, strlen(s));
|
||||||
char* output = (char*)__builtin_alloca(len + 1);
|
nwritten += syscall(SYS_write, "\n", 1);
|
||||||
memcpy(output, s, len);
|
return nwritten;
|
||||||
output[len] = '\n';
|
|
||||||
return syscall(SYS_write, output, len + 1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user