mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-01 15:08:21 +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");
|
printf("init: Welcome to Astral!\n");
|
||||||
|
|
||||||
struct passwd* pw = getpwuid(getuid());
|
struct passwd* pw = getpwuid(getuid());
|
||||||
|
if (pw == NULL) {
|
||||||
|
perror("init: failed to open /etc/passwd");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
if (chdir(pw->pw_dir) == -1) {
|
if (chdir(pw->pw_dir) == -1) {
|
||||||
perror("init: chdir to user home directory failed");
|
perror("init: chdir to user home directory failed");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|||||||
Reference in New Issue
Block a user