mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 12:48:22 +00:00
init: fix possible dereference of null pointer
This commit is contained in:
@@ -8,6 +8,11 @@ int main() {
|
||||
printf("init: Welcome to Astral!\n");
|
||||
|
||||
struct passwd* pw = getpwuid(getuid());
|
||||
if (pw == NULL) {
|
||||
perror("init: failed to open /etc/passwd");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (chdir(pw->pw_dir) == -1) {
|
||||
perror("init: chdir to user home directory failed");
|
||||
return EXIT_FAILURE;
|
||||
|
||||
Reference in New Issue
Block a user