sbonazzo / rpms / cyrus-sasl

Forked from rpms/cyrus-sasl 2 years ago
Clone

Blame SOURCES/cyrus-sasl-2.1.26-null-crypt.patch

6611fc
diff -up cyrus-sasl-2.1.26/pwcheck/pwcheck_getpwnam.c.null-crypt cyrus-sasl-2.1.26/pwcheck/pwcheck_getpwnam.c
6611fc
--- cyrus-sasl-2.1.26/pwcheck/pwcheck_getpwnam.c.null-crypt	2012-01-28 00:31:36.000000000 +0100
6611fc
+++ cyrus-sasl-2.1.26/pwcheck/pwcheck_getpwnam.c	2012-12-20 17:00:14.614580310 +0100
6611fc
@@ -31,7 +31,7 @@ char *pwcheck(userid, password)
6611fc
 char *userid;
6611fc
 char *password;
6611fc
 {
6611fc
-    char* r;
6611fc
+    char* r, *cryptbuf;
6611fc
     struct passwd *pwd;
6611fc
 
6611fc
     pwd = getpwnam(userid);
6611fc
@@ -41,11 +41,13 @@ char *password;
6611fc
     else if (pwd->pw_passwd[0] == '*') {
6611fc
 	r = "Account disabled";
6611fc
     }
6611fc
-    else if (strcmp(pwd->pw_passwd, crypt(password, pwd->pw_passwd)) != 0) {
6611fc
-	r = "Incorrect password";
6611fc
-    }
6611fc
     else {
6611fc
-	r = "OK";
6611fc
+	cryptbuf = crypt(password, pwd->pw_passwd);
6611fc
+	if((cryptbuf == NULL) || (strcmp(pwd->pw_passwd, cryptbuf) != 0)) {
6611fc
+	   r = "Incorrect password";
6611fc
+	} else {
6611fc
+	   r = "OK";
6611fc
+	}
6611fc
     }
6611fc
 
6611fc
     endpwent();
6611fc
diff -up cyrus-sasl-2.1.26/saslauthd/auth_getpwent.c.null-crypt cyrus-sasl-2.1.26/saslauthd/auth_getpwent.c
6611fc
--- cyrus-sasl-2.1.26/saslauthd/auth_getpwent.c.null-crypt	2012-10-12 16:05:48.000000000 +0200
6611fc
+++ cyrus-sasl-2.1.26/saslauthd/auth_getpwent.c	2012-12-20 17:03:17.940793653 +0100
6611fc
@@ -78,6 +78,7 @@ auth_getpwent (
6611fc
     /* VARIABLES */
6611fc
     struct passwd *pw;			/* pointer to passwd file entry */
6611fc
     int errnum;
6611fc
+    char *cryptbuf;
6611fc
     /* END VARIABLES */
6611fc
   
6611fc
     errno = 0;
6611fc
@@ -105,7 +106,8 @@ auth_getpwent (
6611fc
 	}
6611fc
     }
6611fc
 
6611fc
-    if (strcmp(pw->pw_passwd, (const char *)crypt(password, pw->pw_passwd))) {
6611fc
+    cryptbuf = crypt(password, pw->pw_passwd);
6611fc
+    if ((cryptbuf == NULL) || strcmp(pw->pw_passwd, cryptbuf)) {
6611fc
 	if (flags & VERBOSE) {
6611fc
 	    syslog(LOG_DEBUG, "DEBUG: auth_getpwent: %s: invalid password", login);
6611fc
 	}
6611fc
diff -up cyrus-sasl-2.1.26/saslauthd/auth_shadow.c.null-crypt cyrus-sasl-2.1.26/saslauthd/auth_shadow.c
6611fc
--- cyrus-sasl-2.1.26/saslauthd/auth_shadow.c.null-crypt	2012-12-20 17:00:14.000000000 +0100
6611fc
+++ cyrus-sasl-2.1.26/saslauthd/auth_shadow.c	2012-12-20 17:16:44.190360006 +0100
6611fc
@@ -214,8 +214,8 @@ auth_shadow (
6611fc
 	RETURN("NO Insufficient permission to access NIS authentication database (saslauthd)");
6611fc
     }
6611fc
 
6611fc
-    cpw = strdup((const char *)crypt(password, sp->sp_pwdp));
6611fc
-    if (strcmp(sp->sp_pwdp, cpw)) {
6611fc
+    cpw = crypt(password, sp->sp_pwdp);
6611fc
+    if ((cpw == NULL) || strcmp(sp->sp_pwdp, cpw)) {
6611fc
 	if (flags & VERBOSE) {
6611fc
 	    /*
6611fc
 	     * This _should_ reveal the SHADOW_PW_LOCKED prefix to an
6611fc
@@ -225,10 +225,8 @@ auth_shadow (
6611fc
 	    syslog(LOG_DEBUG, "DEBUG: auth_shadow: pw mismatch: '%s' != '%s'",
6611fc
 		   sp->sp_pwdp, cpw);
6611fc
 	}
6611fc
-	free(cpw);
6611fc
 	RETURN("NO Incorrect password");
6611fc
     }
6611fc
-    free(cpw);
6611fc
 
6611fc
     /*
6611fc
      * The following fields will be set to -1 if:
6611fc
@@ -290,7 +288,8 @@ auth_shadow (
6611fc
 	RETURN("NO Invalid username");
6611fc
     }
6611fc
   
6611fc
-    if (strcmp(upw->upw_passwd, crypt(password, upw->upw_passwd)) != 0) {
6611fc
+    cpw = crypt(password, upw->upw_passwd);
6611fc
+    if ((cpw == NULL) || strcmp(upw->upw_passwd, cpw) != 0) {
6611fc
 	if (flags & VERBOSE) {
6611fc
 	    syslog(LOG_DEBUG, "auth_shadow: pw mismatch: %s != %s",
6611fc
 		   password, upw->upw_passwd);