d105766
diff -Naur screen-orig/src/acls.c screen/src/acls.c
d105766
--- screen-orig/src/acls.c	2012-03-07 06:05:35.000000000 -0500
d105766
+++ screen/src/acls.c	2012-04-23 22:57:03.595468724 -0400
d105766
@@ -544,12 +544,25 @@
d105766
 
d105766
       if (pw2 && *pw2 && *pw2 != '\377')	/* provided a system password */
d105766
         {
d105766
-	  if (!*pass ||				/* but needed none */
d105766
-	      strcmp(crypt(pw2, pass), pass))
d105766
+	  if (!*pass)	 			/* but needed none */
d105766
 	    {
d105766
 	      debug("System password mismatch\n");
d105766
 	      sorry++;
d105766
 	    }
d105766
+	  else
d105766
+	    {
d105766
+	      char *cryptbuf =  crypt(pw2, pass);
d105766
+	      if(cryptbuf == NULL) 
d105766
+	       {
d105766
+	        debug("System crypt() failed\n");
d105766
+	        sorry++;
d105766
+	       }
d105766
+	      else if (strcmp(cryptbuf, pass))
d105766
+	       {
d105766
+	      debug("System password mismatch\n");
d105766
+	      sorry++;
d105766
+	       }
d105766
+	    }
d105766
 	}
d105766
       else					/* no pasword provided */
d105766
         if (*pass)				/* but need one */
d105766
@@ -557,12 +570,29 @@
d105766
 #endif
d105766
       if (pw1 && *pw1 && *pw1 != '\377')	/* provided a screen password */
d105766
 	{
d105766
-	  if (!*u->u_password ||		/* but needed none */
d105766
-	      strcmp(crypt(pw1, u->u_password), u->u_password))
d105766
+	 char *cryptbuf;
d105766
+	  if (!*u->u_password)		/* but needed none */
d105766
 	    {
d105766
 	      debug("screen password mismatch\n");
d105766
-              sorry++;
d105766
+	      sorry++;
d105766
 	    }
d105766
+	  else
d105766
+	   {
d105766
+	    cryptbuf = crypt(pw1, u->u_password);
d105766
+	    if (cryptbuf == NULL)
d105766
+	      {
d105766
+		debug("crypt() failed\n");
d105766
+		sorry++;
d105766
+	      }
d105766
+	    else
d105766
+	      {
d105766
+	      if(strcmp(cryptbuf, u->u_password))
d105766
+	       {
d105766
+		debug("screen password mismatch\n");
d105766
+		sorry++;
d105766
+	       }
d105766
+	      }
d105766
+	   }   
d105766
 	}
d105766
       else					/* no pasword provided */
d105766
         if (*u->u_password)			/* but need one */
d105766
diff -Naur screen-orig/src/misc.c screen/src/misc.c
d105766
--- screen-orig/src/misc.c	2012-03-07 06:05:35.000000000 -0500
d105766
+++ screen/src/misc.c	2012-04-23 22:34:56.740665509 -0400
d105766
@@ -56,6 +56,8 @@
d105766
 {
d105766
   register char *cp;
d105766
 
d105766
+  if(str == NULL)
d105766
+    Panic(0, "SaveStr() received NULL - possibly failed crypt()");
d105766
   if ((cp = malloc(strlen(str) + 1)) == NULL)
d105766
     Panic(0, "%s", strnomem);
d105766
   else
d105766
diff -Naur screen-orig/src/process.c screen/src/process.c
d105766
--- screen-orig/src/process.c	2012-03-07 06:05:35.000000000 -0500
d105766
+++ screen/src/process.c	2012-04-23 22:41:09.318930088 -0400
d105766
@@ -6343,6 +6343,10 @@
d105766
 	salt[st] = 'A' + (int)((time(0) >> 6 * st) % 26);
d105766
       salt[2] = 0;
d105766
       buf = crypt(u->u_password, salt);
d105766
+      if(buf == NULL) {
d105766
+        Msg(0, "[ no working crypt() - no secure ]");
d105766
+	return;
d105766
+      }
d105766
       bzero(u->u_password, strlen(u->u_password));
d105766
       free((char *)u->u_password);
d105766
       u->u_password = SaveStr(buf);
d105766
diff -Naur screen-orig/src/socket.c screen/src/socket.c
d105766
--- screen-orig/src/socket.c	2012-04-23 22:17:55.678316716 -0400
d105766
+++ screen/src/socket.c	2012-04-23 22:29:12.225173900 -0400
d105766
@@ -1565,13 +1565,18 @@
d105766
       c = *(unsigned char *)ibuf++;
d105766
       if (c == '\r' || c == '\n')
d105766
 	{
d105766
+	  char *buf;
d105766
 	  up = D_user->u_password;
d105766
 	  pwdata->buf[l] = 0;
d105766
-	  if (strncmp(crypt(pwdata->buf, up), up, strlen(up)))
d105766
+	  buf = crypt(pwdata->buf, up);
d105766
+	  if((buf == NULL) || (strncmp(buf, up, strlen(up))))
d105766
 	    {
d105766
 	      /* uh oh, user failed */
d105766
 	      bzero(pwdata->buf, sizeof(pwdata->buf));
d105766
-	      AddStr("\r\nPassword incorrect.\r\n");
d105766
+	      if(buf==NULL)
d105766
+	      	AddStr("\r\ncrypt() failed.\r\n");
d105766
+	      else
d105766
+	      	AddStr("\r\nPassword incorrect.\r\n");
d105766
 	      D_processinputdata = 0;	/* otherwise freed by FreeDis */
d105766
 	      FreeDisplay();
d105766
 	      Msg(0, "Illegal reattach attempt from terminal %s.", pwdata->m.m_tty);