From 0e216aef4bdf62c1053e827b8d4657e88fda89cf Mon Sep 17 00:00:00 2001 From: Thierry Bordaz Date: Mon, 20 Jan 2020 10:41:08 +0100 Subject: [PATCH] Ticket 50709 - (cont) Several memory leaks reported by Valgrind for 389-ds 1.3.9.1-10 Description of the problem: Original fix was incorrect as it set again in pblock (SLAPI_CONN_CLIENTNETADDR_ACLIP) the same structure. As old structure is freed during the slapi_pblock_set, pblock refers to a freed structure. Later an other threads using the same aclpb contain will use it after free (see https://pagure.io/389-ds-base/issue/50709#comment-621129) Description of the fix: Only sets in pblock a newly allocated structure https://pagure.io/389-ds-base/issue/50709 Reviewed by: Mark Reynolds (Thanks !) --- ldap/servers/plugins/acl/acllas.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ldap/servers/plugins/acl/acllas.c b/ldap/servers/plugins/acl/acllas.c index dd41d41bd..a5602e198 100644 --- a/ldap/servers/plugins/acl/acllas.c +++ b/ldap/servers/plugins/acl/acllas.c @@ -305,7 +305,10 @@ DS_LASIpGetter(NSErr_t *errp, PList_t subject, PList_t resource, PList_t auth_in slapi_log_err(SLAPI_LOG_ACL, plugin_name, "DS_LASIpGetter - " "Returning client ip address 'unknown'\n"); } - slapi_pblock_set(aclpb->aclpb_pblock, SLAPI_CONN_CLIENTNETADDR_ACLIP, client_praddr); + if (client_praddr != pb_client_praddr) { + /* Set it in pblock only if it is newly allocated */ + slapi_pblock_set(aclpb->aclpb_pblock, SLAPI_CONN_CLIENTNETADDR_ACLIP, client_praddr); + } return LAS_EVAL_TRUE; } -- 2.21.1