mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2026-10-25 22:50:12 -05:00
ipa-pwd-extop: fix memory leaks in ipapwd_pre_add()
In `ipapwd_pre_add()`, when processing password from entry extension, `userpw` was reassigned without freeing the previous value. Additionally, `enabled` obtained from `ipapwd_getIpaConfigAttr()` was never freed, and early returns bypassed the cleanup section causing memory leaks. Free `userpw` before reassigning it. Free `enabled` after use. Replace early `return 0` statements with `goto done` to ensure proper cleanup of all allocated resources. Related: https://pagure.io/freeipa/issue/9895 Signed-off-by: Viktor Ashirov <vashirov@redhat.com> Reviewed-By: Alexander Bokovoy <abbra@users.noreply.github.com>
This commit is contained in:
1 parent
1a7819b2c6
commit
28979893e6
1 file changed
+7
-2
@@ -291,6 +291,7 @@ static int ipapwd_pre_add(Slapi_PBlock *pb)
|
||||
slapi_sdn_get_dn(sdn), errMesg);
|
||||
goto done;
|
||||
}
|
||||
slapi_ch_free_string(&userpw);
|
||||
userpw = slapi_ch_strdup(userpw_clear);
|
||||
}
|
||||
|
||||
@@ -302,8 +303,11 @@ static int ipapwd_pre_add(Slapi_PBlock *pb)
|
||||
if (NULL == enabled) {
|
||||
LOG("no ipaMigrationEnabled in config, assuming FALSE\n");
|
||||
} else if (0 == strcmp(enabled, "TRUE")) {
|
||||
return 0;
|
||||
slapi_ch_free_string(&enabled);
|
||||
rc = LDAP_SUCCESS;
|
||||
goto done;
|
||||
}
|
||||
slapi_ch_free_string(&enabled);
|
||||
|
||||
/* With User Life Cycle, it could be a stage user that is activated.
|
||||
* The userPassword and krb keys were set while the user was a stage user.
|
||||
@@ -315,7 +319,8 @@ static int ipapwd_pre_add(Slapi_PBlock *pb)
|
||||
LOG("User Life Cycle: %s is a activated stage user "
|
||||
"(with prehashed password and krb keys)\n",
|
||||
sdn ? slapi_sdn_get_dn(sdn) : "unknown");
|
||||
return 0;
|
||||
rc = LDAP_SUCCESS;
|
||||
goto done;
|
||||
}
|
||||
|
||||
LOG("pre-hashed passwords are not valid\n");
|
||||
|
||||
Reference in new issue
Block a user