Blame SOURCES/screen-4.1.0-crypt.patch

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