Fix segfault on getpwuid failure
This commit is contained in:
parent
c59dd4061d
commit
2ff3dc0619
1 changed files with 15 additions and 5 deletions
|
|
@ -444,8 +444,11 @@ md_getusername(void)
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
|
|
||||||
pw = getpwuid(getuid());
|
pw = getpwuid(getuid());
|
||||||
|
/* Don't segfault if getpwuid fails (and the thing is wildly possible) */
|
||||||
|
if (pw != NULL)
|
||||||
l = pw->pw_name;
|
l = pw->pw_name;
|
||||||
|
else
|
||||||
|
l = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((l == NULL) || (*l == '\0'))
|
if ((l == NULL) || (*l == '\0'))
|
||||||
|
|
@ -475,8 +478,11 @@ md_gethomedir(void)
|
||||||
char slash = '/';
|
char slash = '/';
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
pw = getpwuid(getuid());
|
pw = getpwuid(getuid());
|
||||||
|
/* Don't segfault if getpwuid fails */
|
||||||
|
if (pw != NULL)
|
||||||
h = pw->pw_dir;
|
h = pw->pw_dir;
|
||||||
|
else
|
||||||
|
h = NULL;
|
||||||
|
|
||||||
if (strcmp(h,"/") == 0)
|
if (strcmp(h,"/") == 0)
|
||||||
h = NULL;
|
h = NULL;
|
||||||
|
|
@ -540,7 +546,11 @@ md_getshell(void)
|
||||||
char *def = "/bin/sh";
|
char *def = "/bin/sh";
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
pw = getpwuid(getuid());
|
pw = getpwuid(getuid());
|
||||||
|
/* don't segfault if getpwuid fails */
|
||||||
|
if (pw != NULL)
|
||||||
s = pw->pw_shell;
|
s = pw->pw_shell;
|
||||||
|
else
|
||||||
|
s = NULL;
|
||||||
#endif
|
#endif
|
||||||
if ((s == NULL) || (*s == '\0'))
|
if ((s == NULL) || (*s == '\0'))
|
||||||
if ( (s = getenv("COMSPEC")) == NULL)
|
if ( (s = getenv("COMSPEC")) == NULL)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue