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,7 +244,8 @@ md_getusername(int uid)
|
|||
|
||||
pw = getpwuid(getuid());
|
||||
|
||||
l = pw->pw_name;
|
||||
if (pw != NULL)
|
||||
l = pw->pw_name;
|
||||
#endif
|
||||
|
||||
if ((l == NULL) || (*l == '\0'))
|
||||
|
|
@ -275,7 +276,8 @@ md_gethomedir()
|
|||
struct passwd *pw;
|
||||
pw = getpwuid(getuid());
|
||||
|
||||
h = pw->pw_dir;
|
||||
if (pw != NULL)
|
||||
h = pw->pw_dir;
|
||||
|
||||
if (strcmp(h,"/") == 0)
|
||||
h = NULL;
|
||||
|
|
@ -335,7 +337,8 @@ md_getshell()
|
|||
char *def = "/bin/sh";
|
||||
struct passwd *pw;
|
||||
pw = getpwuid(getuid());
|
||||
s = pw->pw_shell;
|
||||
if (pw != NULL)
|
||||
s = pw->pw_shell;
|
||||
#endif
|
||||
if ((s == NULL) || (*s == '\0'))
|
||||
if ( (s = getenv("COMSPEC")) == NULL)
|
||||
|
|
@ -455,13 +458,13 @@ md_getrealname(int uid)
|
|||
#if !defined(_WIN32) && !defined(DJGPP)
|
||||
struct passwd *pp;
|
||||
|
||||
if ((pp = getpwuid(uid)) == NULL)
|
||||
if ((pp = getpwuid(uid)) == NULL)
|
||||
{
|
||||
sprintf(uidstr,"%d", uid);
|
||||
return(uidstr);
|
||||
}
|
||||
else
|
||||
return(pp->pw_name);
|
||||
else
|
||||
return(pp->pw_name);
|
||||
#else
|
||||
sprintf(uidstr,"%d", uid);
|
||||
return(uidstr);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue