mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 04:25:13 +00:00
LibC: Don't leave /etc/passwd open in getlogin()
This commit is contained in:
parent
e1d4b19461
commit
03c34cc73f
Notes:
sideshowbarker
2024-07-19 10:15:38 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/03c34cc73fe
1 changed files with 2 additions and 0 deletions
|
@ -516,8 +516,10 @@ char* getlogin()
|
|||
static char __getlogin_buffer[256];
|
||||
if (auto* passwd = getpwuid(getuid())) {
|
||||
strncpy(__getlogin_buffer, passwd->pw_name, sizeof(__getlogin_buffer));
|
||||
endpwent();
|
||||
return __getlogin_buffer;
|
||||
}
|
||||
endpwent();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue