andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 months ago
Clone
dc8c34
From 79ffa81a6fe6d310f26979d61dbf79364ee9a668 Mon Sep 17 00:00:00 2001
dc8c34
From: Noriko Hosoi <nhosoi@redhat.com>
dc8c34
Date: Fri, 9 Jan 2015 14:22:50 -0800
dc8c34
Subject: [PATCH 299/305] Ticket #47905 - Bad manipulation of passwordhistory
dc8c34
dc8c34
Description: The patch was provided by German Parente (gparente@redhat.com)
dc8c34
https://fedorahosted.org/389/ticket/47905#comment:6
dc8c34
dc8c34
If a value of password policy attribute (e.g., passwordhistory) is
dc8c34
accidentally deleted, it causes a null reference in pw_val2scheme.
dc8c34
This patch checks whether val is NULL or not.  If the given val is
dc8c34
NULL, pw_val2scheme returns NULL.
dc8c34
dc8c34
https://fedorahosted.org/389/ticket/47905
dc8c34
dc8c34
Reviewed by nhosoi@redhat.com.
dc8c34
dc8c34
(cherry picked from commit 2c6e74adbea3c4799f30b0e3d679da9dd060ff58)
dc8c34
(cherry picked from commit baa26c96e873916d4c02651b04de7ca2a578863d)
dc8c34
(cherry picked from commit a9dee00b79016a51ebfed01c92267b751c5986de)
dc8c34
(cherry picked from commit bf274554956196b4fc3f80f60c1b61de28a1b9d2)
dc8c34
(cherry picked from commit 6b85c3a655896363826fe5aacee9e7493fcb9ca9)
dc8c34
---
dc8c34
 ldap/servers/slapd/pw.c | 7 +++++--
dc8c34
 1 file changed, 5 insertions(+), 2 deletions(-)
dc8c34
dc8c34
diff --git a/ldap/servers/slapd/pw.c b/ldap/servers/slapd/pw.c
dc8c34
index 0349c5a..73fcfa9 100644
dc8c34
--- a/ldap/servers/slapd/pw.c
dc8c34
+++ b/ldap/servers/slapd/pw.c
dc8c34
@@ -145,7 +145,7 @@ slapi_pw_find_sv(
dc8c34
 
dc8c34
 	LDAPDebug( LDAP_DEBUG_TRACE, "=> slapi_pw_find value: \"%s\"\n", slapi_value_get_string(v), 0, 0 ); /* JCM Innards */
dc8c34
 
dc8c34
-    for ( i = 0; vals[i] != NULL; i++ )
dc8c34
+    for ( i = 0; vals && vals[i]; i++ )
dc8c34
     {
dc8c34
 		pwsp = pw_val2scheme( (char*)slapi_value_get_string(vals[i]), &valpwd, 1 ); /* JCM Innards*/
dc8c34
 		if ( pwsp != NULL && 
dc8c34
@@ -287,9 +287,12 @@ struct pw_scheme *
dc8c34
 pw_val2scheme( char *val, char **valpwdp, int first_is_default )
dc8c34
 {
dc8c34
 	struct pw_scheme	*pwsp;
dc8c34
-    int     		namelen, prefixlen;
dc8c34
+	int 			namelen, prefixlen;
dc8c34
 	char			*end, buf[ PWD_MAX_NAME_LEN + 1 ];
dc8c34
 
dc8c34
+	if (NULL == val) {
dc8c34
+		return( NULL );
dc8c34
+	}
dc8c34
 	if ( *val != PWD_HASH_PREFIX_START ||
dc8c34
 	    ( end = strchr( val, PWD_HASH_PREFIX_END )) == NULL ||
dc8c34
 	    ( namelen = end - val - 1 ) > PWD_MAX_NAME_LEN ) {
dc8c34
-- 
dc8c34
1.9.3
dc8c34