diff arogue5/mdport.c @ 72:46f39359c4a7

arogue5: avoid segfaulting if getpwuid() fails.
author elwin
date Sat, 11 Aug 2012 23:45:34 +0000
parents c49f7927b0fa
children 3192c1e03970
line wrap: on
line diff
--- a/arogue5/mdport.c	Sat Aug 11 21:58:20 2012 +0000
+++ b/arogue5/mdport.c	Sat Aug 11 23:45:34 2012 +0000
@@ -234,7 +234,10 @@
 
     pw = getpwuid(getuid());
 
-    l = pw->pw_name;
+    if (pw != NULL)
+        l = pw->pw_name;
+    else
+        l = "";
 #endif
 
     if ((l == NULL) || (*l == '\0'))
@@ -265,7 +268,10 @@
     struct passwd *pw;
     pw = getpwuid(getuid());
 
-    h = pw->pw_dir;
+    if (pw != NULL)
+        h = pw->pw_dir;
+    else
+        h = "";
 
     if (strcmp(h,"/") == 0)
         h = NULL;
@@ -325,7 +331,10 @@
     char *def = "/bin/sh";
     struct passwd *pw;
     pw = getpwuid(getuid());
-    s = pw->pw_shell;
+    if (pw != NULL)
+        s = pw->pw_shell;
+    else
+        s = "";
 #endif
     if ((s == NULL) || (*s == '\0'))
         if ( (s = getenv("COMSPEC")) == NULL)