andykimpe / rpms / 389-ds-base

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