arogue5: avoid segfaulting if getpwuid() fails.
This commit is contained in:
parent
6e2b154419
commit
355fb33eb7
2 changed files with 14 additions and 5 deletions
|
|
@ -234,7 +234,10 @@ md_getusername()
|
|||
|
||||
pw = getpwuid(getuid());
|
||||
|
||||
l = pw->pw_name;
|
||||
if (pw != NULL)
|
||||
l = pw->pw_name;
|
||||
else
|
||||
l = "";
|
||||
#endif
|
||||
|
||||
if ((l == NULL) || (*l == '\0'))
|
||||
|
|
@ -265,7 +268,10 @@ md_gethomedir()
|
|||
struct passwd *pw;
|
||||
pw = getpwuid(getuid());
|
||||
|
||||
h = pw->pw_dir;
|
||||
if (pw != NULL)
|
||||
h = pw->pw_dir;
|
||||
else
|
||||
h = "";
|
||||
|
||||
if (strcmp(h,"/") == 0)
|
||||
h = NULL;
|
||||
|
|
@ -325,7 +331,10 @@ md_getshell()
|
|||
char *def = "/bin/sh";
|
||||
struct passwd *pw;
|
||||
pw = getpwuid(getuid());
|
||||
s = pw->pw_shell;
|
||||
if (pw != NULL)
|
||||
s = pw->pw_shell;
|
||||
else
|
||||
s = "";
|
||||
#endif
|
||||
if ((s == NULL) || (*s == '\0'))
|
||||
if ( (s = getenv("COMSPEC")) == NULL)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue