Selaa lähdekoodia

Bug 553455 - fix segfault when changing a password

If a local password policy is set that does not have a storage
scheme specified, the server can crash since it tries to dereference
a NULL pointer to access the hashing function.  This fix simply
checks if the storage scheme is set before trying to access the
hashing function.
Nathan Kinder 16 vuotta sitten
vanhempi
sitoutus
786c740c39
1 muutettua tiedostoa jossa 6 lisäystä ja 2 poistoa
  1. 6 2
      ldap/servers/slapd/pw.c

+ 6 - 2
ldap/servers/slapd/pw.c

@@ -350,8 +350,12 @@ pw_encodevals_ext( Slapi_PBlock *pb, const Slapi_DN *sdn, Slapi_Value **vals )
  
 	/* new_passwdPolicy gives us a local policy if sdn and pb are set and
 	   can be used to find a local policy, else we get the global policy */
-   	pwpolicy = new_passwdPolicy(pb, sdn ? (char*)slapi_sdn_get_ndn(sdn) : NULL );
-	pws_enc = pwpolicy->pw_storagescheme->pws_enc;
+	pwpolicy = new_passwdPolicy(pb, sdn ? (char*)slapi_sdn_get_ndn(sdn) : NULL );
+
+	if (pwpolicy->pw_storagescheme) {
+		pws_enc = pwpolicy->pw_storagescheme->pws_enc;
+	}
+
 	delete_passwdPolicy(&pwpolicy);
 
 	/* Password scheme encryption function was not found */