UltraRogue: check the return value from getpwuid().

It is possible for getpwuid() to return NULL.  Such a failure will no
longer cause a segfault.  However, the call to getpwuid() may normally
not be reachable.
This commit is contained in:
John "Elwin" Edwards 2017-03-01 20:40:18 -05:00
parent ee3408932f
commit 9a9c016bae

View file

@ -244,6 +244,7 @@ md_getusername(int uid)
pw = getpwuid(getuid()); pw = getpwuid(getuid());
if (pw != NULL)
l = pw->pw_name; l = pw->pw_name;
#endif #endif
@ -275,6 +276,7 @@ md_gethomedir()
struct passwd *pw; struct passwd *pw;
pw = getpwuid(getuid()); pw = getpwuid(getuid());
if (pw != NULL)
h = pw->pw_dir; h = pw->pw_dir;
if (strcmp(h,"/") == 0) if (strcmp(h,"/") == 0)
@ -335,6 +337,7 @@ md_getshell()
char *def = "/bin/sh"; char *def = "/bin/sh";
struct passwd *pw; struct passwd *pw;
pw = getpwuid(getuid()); pw = getpwuid(getuid());
if (pw != NULL)
s = pw->pw_shell; s = pw->pw_shell;
#endif #endif
if ((s == NULL) || (*s == '\0')) if ((s == NULL) || (*s == '\0'))