andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 months ago
Clone

Blame SOURCES/0010-Fix-double-free-in-_cl5NewDBFile-error-path.patch

b69e47
From 8c39c9dbe69949065940019e930c37b8f5450a75 Mon Sep 17 00:00:00 2001
b69e47
From: Adam Tkac <vonsch@gmail.com>
b69e47
Date: Sat, 18 Mar 2017 23:34:54 +0100
b69e47
Subject: [PATCH] Fix double-free in _cl5NewDBFile() error path
b69e47
b69e47
Although slapi_ch_free should prevent double-free errors, it doesn't work
b69e47
in old code because after assignment
b69e47
b69e47
(*dbFile)->name = name;
b69e47
b69e47
two independent pointers points to the same allocated area and both pointers
b69e47
are free()-ed (one directly in error path in _cl5NewDBFile and the second
b69e47
in _cl5DBCloseFile, called in error path as well).
b69e47
b69e47
Signed-off-by: Mark Reynolds <mreynolds@redhat.com>
b69e47
---
b69e47
 ldap/servers/plugins/replication/cl5_api.c | 7 ++++---
b69e47
 1 file changed, 4 insertions(+), 3 deletions(-)
b69e47
b69e47
diff --git a/ldap/servers/plugins/replication/cl5_api.c b/ldap/servers/plugins/replication/cl5_api.c
b69e47
index fc70ab7..5c2233f 100644
b69e47
--- a/ldap/servers/plugins/replication/cl5_api.c
b69e47
+++ b/ldap/servers/plugins/replication/cl5_api.c
b69e47
@@ -6269,9 +6269,10 @@ out:
b69e47
 	}
b69e47
 
b69e47
     (*dbFile)->db = db;
b69e47
-    (*dbFile)->name = name;  
b69e47
-    (*dbFile)->replName = slapi_ch_strdup (replName);  
b69e47
-    (*dbFile)->replGen = slapi_ch_strdup (replGen);  
b69e47
+    (*dbFile)->name = name;
b69e47
+    name = NULL; /* transfer ownership to dbFile struct */
b69e47
+    (*dbFile)->replName = slapi_ch_strdup (replName);
b69e47
+    (*dbFile)->replGen = slapi_ch_strdup (replGen);
b69e47
 
b69e47
 	/*
b69e47
 	 * Considerations for setting up cl semaphore:
b69e47
-- 
b69e47
2.9.3
b69e47