diff --git a/urogue/mdport.c b/urogue/mdport.c index ae19272..827a6b9 100644 --- a/urogue/mdport.c +++ b/urogue/mdport.c @@ -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);