1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 13:47:45 +00:00

LibC: Fix truncated strncpy() in getlogin()

This commit is contained in:
Andreas Kling 2020-04-13 11:58:00 +02:00
parent dda9ffe906
commit d1ffdea550

View file

@ -538,7 +538,7 @@ char* getlogin()
{ {
static char __getlogin_buffer[256]; static char __getlogin_buffer[256];
if (auto* passwd = getpwuid(getuid())) { if (auto* passwd = getpwuid(getuid())) {
strncpy(__getlogin_buffer, passwd->pw_name, sizeof(__getlogin_buffer)); strncpy(__getlogin_buffer, passwd->pw_name, sizeof(__getlogin_buffer) - 1);
endpwent(); endpwent();
return __getlogin_buffer; return __getlogin_buffer;
} }