arogue7, xrogue: prevent potential NULL dereferencing.
It is possible for getpwuid() to fail and return NULL. Various md_get* functions now check for this.
This commit is contained in:
parent
3554339257
commit
ea4244de91
2 changed files with 20 additions and 12 deletions
|
|
@ -235,7 +235,8 @@ md_getusername()
|
|||
|
||||
pw = getpwuid(getuid());
|
||||
|
||||
l = pw->pw_name;
|
||||
if (pw != NULL)
|
||||
l = pw->pw_name;
|
||||
#endif
|
||||
|
||||
if ((l == NULL) || (*l == '\0'))
|
||||
|
|
@ -266,10 +267,12 @@ md_gethomedir()
|
|||
struct passwd *pw;
|
||||
pw = getpwuid(getuid());
|
||||
|
||||
h = pw->pw_dir;
|
||||
|
||||
if (strcmp(h,"/") == 0)
|
||||
h = NULL;
|
||||
if (pw != NULL)
|
||||
{
|
||||
h = pw->pw_dir;
|
||||
if (strcmp(h,"/") == 0)
|
||||
h = NULL;
|
||||
}
|
||||
#endif
|
||||
homedir[0] = 0;
|
||||
#ifdef _WIN32
|
||||
|
|
@ -326,7 +329,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)
|
||||
|
|
|
|||
|
|
@ -2994,7 +2994,8 @@ md_getusername()
|
|||
|
||||
pw = getpwuid(getuid());
|
||||
|
||||
l = pw->pw_name;
|
||||
if (pw != NULL)
|
||||
l = pw->pw_name;
|
||||
#endif
|
||||
|
||||
if ((l == NULL) || (*l == '\0'))
|
||||
|
|
@ -3025,10 +3026,12 @@ md_gethomedir()
|
|||
struct passwd *pw;
|
||||
pw = getpwuid(getuid());
|
||||
|
||||
h = pw->pw_dir;
|
||||
|
||||
if (strcmp(h,"/") == 0)
|
||||
h = NULL;
|
||||
if (pw != NULL)
|
||||
{
|
||||
h = pw->pw_dir;
|
||||
if (strcmp(h,"/") == 0)
|
||||
h = NULL;
|
||||
}
|
||||
#endif
|
||||
homedir[0] = 0;
|
||||
|
||||
|
|
@ -3124,7 +3127,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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue