Blame SOURCES/cvs-1.11.23-crypt-2.diff

814382
From f3ba6614adc715b658fa7ba8de380c5890665de5 Mon Sep 17 00:00:00 2001
814382
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
814382
Date: Wed, 5 Jun 2013 09:08:42 +0200
814382
Subject: [PATCH] crypt(3) can return NULL
814382
814382
crypt(3) can fail and return NULL since glibc-2.17. This patch
814382
prevents from crashing CVS in that case.
814382
814382
Patch ported from upstream report
814382
<https://savannah.nongnu.org/bugs/index.php?39040> developed by
814382
<mancha1@hush.com>.
814382
---
814382
 src/server.c | 14 +++++++++-----
814382
 1 file changed, 9 insertions(+), 5 deletions(-)
814382
814382
diff --git a/src/server.c b/src/server.c
814382
index bc6f0d0..348338c 100644
814382
--- a/src/server.c
814382
+++ b/src/server.c
814382
@@ -5647,9 +5647,11 @@ check_repository_password (username, password, repository, host_user_ptr)
814382
 	    host_user_tmp = username;
814382
 
814382
 	/* Verify blank passwords directly, otherwise use crypt(). */
814382
+	char *crypt_passwd = found_password ? crypt (password, found_password): NULL;
814382
 	if ((found_password == NULL)
814382
-	    || ((strcmp (found_password, crypt (password, found_password))
814382
-		 == 0)))
814382
+	    || (crypt_passwd != NULL
814382
+               && (strcmp (found_password, crypt_passwd)
814382
+		    == 0)))
814382
 	{
814382
 	    /* Give host_user_ptr permanent storage. */
814382
 	    *host_user_ptr = xstrdup (host_user_tmp);
814382
@@ -5660,7 +5662,7 @@ check_repository_password (username, password, repository, host_user_ptr)
814382
 #ifdef LOG_AUTHPRIV
814382
 	syslog (LOG_AUTHPRIV | LOG_NOTICE,
814382
 		"password mismatch for %s in %s: %s vs. %s", username,
814382
-		repository, crypt(password, found_password), found_password);
814382
+		repository, crypt_passwd, found_password);
814382
 #endif
814382
 	    *host_user_ptr = NULL;
814382
 	    retval	 = 2;
814382
@@ -5869,7 +5871,9 @@ error %s getnameinfo failed\n", strerror (errno));
814382
             pamh = NULL;
814382
         }
814382
 #else
814382
-	if (strcmp (found_passwd, crypt (password, found_passwd)) == 0)
814382
+	char *crypt_passwd = crypt (password, found_passwd);
814382
+	if ((crypt_passwd != NULL) &&
814382
+	    (strcmp (found_passwd, crypt_passwd) == 0))
814382
 	{
814382
 	    host_user = xstrdup (username);
814382
 	}
814382
@@ -5879,7 +5883,7 @@ error %s getnameinfo failed\n", strerror (errno));
814382
 #ifdef LOG_AUTHPRIV
814382
 	    syslog (LOG_AUTHPRIV | LOG_NOTICE,
814382
 		    "password mismatch for %s: %s vs. %s", username,
814382
-		    crypt(password, found_passwd), found_passwd);
814382
+		    crypt_passwd, found_passwd);
814382
 #endif
814382
 	}
814382
 #endif
814382
-- 
814382
1.8.1.4
814382