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:
parent
ee3408932f
commit
9a9c016bae
1 changed files with 9 additions and 6 deletions
|
|
@ -244,6 +244,7 @@ md_getusername(int uid)
|
|||
|
||||
pw = getpwuid(getuid());
|
||||
|
||||
if (pw != NULL)
|
||||
l = pw->pw_name;
|
||||
#endif
|
||||
|
||||
|
|
@ -275,6 +276,7 @@ md_gethomedir()
|
|||
struct passwd *pw;
|
||||
pw = getpwuid(getuid());
|
||||
|
||||
if (pw != NULL)
|
||||
h = pw->pw_dir;
|
||||
|
||||
if (strcmp(h,"/") == 0)
|
||||
|
|
@ -335,6 +337,7 @@ md_getshell()
|
|||
char *def = "/bin/sh";
|
||||
struct passwd *pw;
|
||||
pw = getpwuid(getuid());
|
||||
if (pw != NULL)
|
||||
s = pw->pw_shell;
|
||||
#endif
|
||||
if ((s == NULL) || (*s == '\0'))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue