andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 months ago
Clone

Blame SOURCES/0047-Ticket-48975-Disabling-CLEAR-password-storage-scheme.patch

7c7f29
From eaf8b3b97e22bf06152d42b90940212e7acc8e00 Mon Sep 17 00:00:00 2001
7c7f29
From: Mark Reynolds <mreynolds@redhat.com>
7c7f29
Date: Tue, 30 Aug 2016 14:25:15 -0400
7c7f29
Subject: [PATCH 47/47] Ticket 48975- Disabling CLEAR password storage scheme
7c7f29
 will  crash server when setting a password
7c7f29
7c7f29
Bug Description:  If the CLEAR password storage scheme plugin is disabled, and a
7c7f29
                  userpassword is set, the server crashes.  This is because we
7c7f29
                  expect this plugin to be enabled when working with the unhashed
7c7f29
                  password.
7c7f29
7c7f29
Fix Description:  Always check if the password scheme, returned by pw_val2scheme(),
7c7f29
                  is NULL before dereferencing it.  If it is NULL treat it as a
7c7f29
                  clear text password.
7c7f29
7c7f29
Valgrind: Passed
7c7f29
7c7f29
https://fedorahosted.org/389/ticket/48975
7c7f29
7c7f29
Reviewed by: nhosoi(Thanks!)
7c7f29
7c7f29
(cherry picked from commit 52230585a1191bf1e747780b592f291d652e26dd)
7c7f29
---
7c7f29
 ldap/servers/slapd/modify.c | 8 ++++----
7c7f29
 ldap/servers/slapd/pw.c     | 4 ++--
7c7f29
 2 files changed, 6 insertions(+), 6 deletions(-)
7c7f29
7c7f29
diff --git a/ldap/servers/slapd/modify.c b/ldap/servers/slapd/modify.c
7c7f29
index 4a5faa0..72f2db4 100644
7c7f29
--- a/ldap/servers/slapd/modify.c
7c7f29
+++ b/ldap/servers/slapd/modify.c
7c7f29
@@ -827,7 +827,7 @@ static void op_shared_modify (Slapi_PBlock *pb, int pw_change, char *old_pw)
7c7f29
 				for ( i = 0; pw_mod->mod_bvalues != NULL && pw_mod->mod_bvalues[i] != NULL; i++ ) {
7c7f29
 					password = slapi_ch_strdup(pw_mod->mod_bvalues[i]->bv_val);
7c7f29
 					pwsp = pw_val2scheme( password, &valpwd, 1 );
7c7f29
-					if(strcmp(pwsp->pws_name, "CLEAR") == 0){
7c7f29
+					if(pwsp == NULL || strcmp(pwsp->pws_name, "CLEAR") == 0){
7c7f29
 						/*
7c7f29
 						 *  CLEAR password
7c7f29
 						 *
7c7f29
@@ -851,7 +851,7 @@ static void op_shared_modify (Slapi_PBlock *pb, int pw_change, char *old_pw)
7c7f29
 								const char *userpwd = slapi_value_get_string(present_values[ii]);
7c7f29
 
7c7f29
 								pass_scheme = pw_val2scheme( (char *)userpwd, &pval, 1 );
7c7f29
-								if(strcmp(pass_scheme->pws_name,"CLEAR")){
7c7f29
+								if(pass_scheme && strcmp(pass_scheme->pws_name,"CLEAR")){
7c7f29
 									/* its encoded, so compare it */
7c7f29
 									if((*(pass_scheme->pws_cmp))( valpwd, pval ) == 0 ){
7c7f29
 									    /*
7c7f29
@@ -912,7 +912,7 @@ static void op_shared_modify (Slapi_PBlock *pb, int pw_change, char *old_pw)
7c7f29
 								 *  provided by the client.
7c7f29
 								 */
7c7f29
 								unhashed_pwsp = pw_val2scheme( (char *)unhashed_pwd, NULL, 1 );
7c7f29
-								if(strcmp(unhashed_pwsp->pws_name, "CLEAR") == 0){
7c7f29
+								if(unhashed_pwsp == NULL || strcmp(unhashed_pwsp->pws_name, "CLEAR") == 0){
7c7f29
 									if((*(pwsp->pws_cmp))((char *)unhashed_pwd , valpwd) == 0 ){
7c7f29
 										/* match, add the delete mod for this particular unhashed userpassword */
7c7f29
 										if (SLAPD_UNHASHED_PW_OFF != config_get_unhashed_pw_switch()) {
7c7f29
@@ -1156,7 +1156,7 @@ valuearray_init_bervalarray_unhashed_only(struct berval **bvals, Slapi_Value ***
7c7f29
 		*cvals = (Slapi_Value **) slapi_ch_malloc((n + 1) * sizeof(Slapi_Value *));
7c7f29
 		for(i=0,p=0;i
7c7f29
 			pwsp = pw_val2scheme( bvals[i]->bv_val, NULL, 1 );
7c7f29
-			if(strcmp(pwsp->pws_name, "CLEAR") == 0){
7c7f29
+			if(pwsp == NULL || strcmp(pwsp->pws_name, "CLEAR") == 0){
7c7f29
 				(*cvals)[p++] = slapi_value_new_berval(bvals[i]);
7c7f29
 			}
7c7f29
 			free_pw_scheme( pwsp );
7c7f29
diff --git a/ldap/servers/slapd/pw.c b/ldap/servers/slapd/pw.c
7c7f29
index 3f2cdb0..6f02f90 100644
7c7f29
--- a/ldap/servers/slapd/pw.c
7c7f29
+++ b/ldap/servers/slapd/pw.c
7c7f29
@@ -234,8 +234,8 @@ void free_pw_scheme(struct pw_scheme *pwsp)
7c7f29
 {
7c7f29
 	if ( pwsp != NULL )
7c7f29
 	{
7c7f29
-		slapi_ch_free( (void**)&pwsp->pws_name );
7c7f29
-		slapi_ch_free( (void**)&pwsp );
7c7f29
+		slapi_ch_free_string(&pwsp->pws_name);
7c7f29
+		slapi_ch_free((void**)&pwsp);
7c7f29
 	}
7c7f29
 }
7c7f29
 
7c7f29
-- 
7c7f29
2.4.11
7c7f29