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,6 +235,7 @@ md_getusername()
|
||||||
|
|
||||||
pw = getpwuid(getuid());
|
pw = getpwuid(getuid());
|
||||||
|
|
||||||
|
if (pw != NULL)
|
||||||
l = pw->pw_name;
|
l = pw->pw_name;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -266,10 +267,12 @@ 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)
|
||||||
h = NULL;
|
h = NULL;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
homedir[0] = 0;
|
homedir[0] = 0;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
@ -326,6 +329,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'))
|
||||||
|
|
|
||||||
|
|
@ -2994,6 +2994,7 @@ md_getusername()
|
||||||
|
|
||||||
pw = getpwuid(getuid());
|
pw = getpwuid(getuid());
|
||||||
|
|
||||||
|
if (pw != NULL)
|
||||||
l = pw->pw_name;
|
l = pw->pw_name;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -3025,10 +3026,12 @@ 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)
|
||||||
h = NULL;
|
h = NULL;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
homedir[0] = 0;
|
homedir[0] = 0;
|
||||||
|
|
||||||
|
|
@ -3124,6 +3127,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'))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue