1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 23:48:11 +00:00

LibC: Prefer strlcpy over strcpy/strncpy

All of these are cosmetic (I believe). Furthermore, they serve as
reminders to always check the length of the destination buffers.
This commit is contained in:
Ben Wiederhake 2020-08-23 19:08:02 +02:00 committed by Andreas Kling
parent aa36e9917c
commit d419a780ae
3 changed files with 13 additions and 13 deletions

View file

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