kay / rpms / cyrus-sasl

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