File netkit-rsh-0.17-pam.diff of Package rsh

--- rshd/rshd.c
+++ rshd/rshd.c
@@ -233,8 +233,36 @@
     static struct pam_conv conv = { misc_conv, NULL };
     int retcode;
 #endif
-    struct passwd *pwd = getpwnam(locuser);
+    struct passwd *pwd, *pwd_tmp = getpwnam(locuser);
+    if (pwd_tmp == NULL) return NULL;
+
+    pwd = (struct passwd*) malloc(sizeof(struct passwd));
     if (pwd == NULL) return NULL;
+
+    pwd->pw_name = (char *) malloc(strlen(pwd_tmp->pw_name)+1);
+    if (pwd->pw_name == NULL) return NULL;
+    strncpy(pwd->pw_name, pwd_tmp->pw_name, strlen(pwd_tmp->pw_name)+1);
+
+    pwd->pw_passwd = (char *) malloc(strlen(pwd_tmp->pw_passwd)+1);
+    if (pwd->pw_passwd == NULL) return NULL;
+    strncpy(pwd->pw_passwd, pwd_tmp->pw_passwd, strlen(pwd_tmp->pw_passwd)+1);
+
+    pwd->pw_uid = pwd_tmp->pw_uid;
+    pwd->pw_gid = pwd_tmp->pw_gid;
+
+    pwd->pw_gecos = (char *) malloc(strlen(pwd_tmp->pw_gecos)+1);
+    if (pwd->pw_gecos == NULL) return NULL;
+    strncpy(pwd->pw_gecos, pwd_tmp->pw_gecos, strlen(pwd_tmp->pw_gecos)+1); 
+
+    pwd->pw_dir = (char *) malloc(strlen(pwd_tmp->pw_dir)+1);
+    if (pwd->pw_dir == NULL) return NULL;
+    strncpy(pwd->pw_dir, pwd_tmp->pw_dir, strlen(pwd_tmp->pw_dir)+1); 
+
+    pwd->pw_shell = (char *) malloc(strlen(pwd_tmp->pw_shell)+1);
+    if (pwd->pw_shell == NULL) return NULL;
+    strncpy(pwd->pw_shell, pwd_tmp->pw_shell, strlen(pwd_tmp->pw_shell)+1); 
+
+
     if (pwd->pw_uid==0) paranoid = 1;
 
 #ifdef USE_PAM