mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-01-28 17:14:38 -06:00
slapi_pw_find_sv() expects an array, make sure we have a NULL terminated
one to avoid potential segfaults Avoid leaking memory too.
This commit is contained in:
parent
2dc64eddd4
commit
f5d9dd647f
@ -1263,19 +1263,23 @@ static int ipapwd_CheckPolicy(struct ipapwd_data *data)
|
|||||||
/* first of all check current password, if any */
|
/* first of all check current password, if any */
|
||||||
old_pw = slapi_entry_attr_get_charptr(data->target, "userPassword");
|
old_pw = slapi_entry_attr_get_charptr(data->target, "userPassword");
|
||||||
if (old_pw) {
|
if (old_pw) {
|
||||||
Slapi_Value *cpw;
|
Slapi_Value *cpw[2] = {NULL, NULL};
|
||||||
Slapi_Value *pw;
|
Slapi_Value *pw;
|
||||||
|
|
||||||
cpw = slapi_value_new_string(old_pw);
|
cpw[0] = slapi_value_new_string(old_pw);
|
||||||
pw = slapi_value_new_string(data->password);
|
pw = slapi_value_new_string(data->password);
|
||||||
if (!cpw || !pw) {
|
if (!cpw[0] || !pw) {
|
||||||
slapi_log_error(SLAPI_LOG_PLUGIN, "ipa_pwd_extop",
|
slapi_log_error(SLAPI_LOG_PLUGIN, "ipa_pwd_extop",
|
||||||
"ipapwd_checkPassword: Out of Memory\n");
|
"ipapwd_checkPassword: Out of Memory\n");
|
||||||
slapi_entry_free(policy);
|
slapi_entry_free(policy);
|
||||||
|
slapi_value_free(&cpw[0]);
|
||||||
|
slapi_value_free(&pw);
|
||||||
return LDAP_OPERATIONS_ERROR;
|
return LDAP_OPERATIONS_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = slapi_pw_find_sv(&cpw, pw);
|
ret = slapi_pw_find_sv(cpw, pw);
|
||||||
|
slapi_value_free(&cpw[0]);
|
||||||
|
slapi_value_free(&pw);
|
||||||
|
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
slapi_log_error(SLAPI_LOG_TRACE, "ipa_pwd_extop",
|
slapi_log_error(SLAPI_LOG_TRACE, "ipa_pwd_extop",
|
||||||
|
Loading…
Reference in New Issue
Block a user