Blame SOURCES/0015-Ticket-50709-cont-Several-memory-leaks-reported-by-V.patch

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