Blame SOURCES/screen-4.1.0-crypt.patch

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