From 86dcb5c471e440cc3937adce394e7d263f8226fc Mon Sep 17 00:00:00 2001 From: Bananymous Date: Wed, 11 Sep 2024 22:11:05 +0300 Subject: [PATCH] init: Don't leak pwent fd to child processes --- userspace/programs/init/main.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/userspace/programs/init/main.cpp b/userspace/programs/init/main.cpp index de27da96..1cdd1d74 100644 --- a/userspace/programs/init/main.cpp +++ b/userspace/programs/init/main.cpp @@ -114,7 +114,12 @@ int main() setenv("HOME", pwd->pw_dir, 1); chdir(pwd->pw_dir); - execl(pwd->pw_shell, pwd->pw_shell, nullptr); + char shell_path[PATH_MAX]; + strcpy(shell_path, pwd->pw_shell); + + endpwent(); + + execl(shell_path, shell_path, nullptr); perror("execl"); exit(1);