Do not use __builtin_alloca in puts (could overflow the stack for large strings)

This commit is contained in:
apio 2022-10-03 19:05:04 +02:00
parent 34aa953dbc
commit 9420484c9b

View File

@ -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;
}
}