[PATCH 02/27] eventlog: don't leak state_path onto talloc tos

David Disseldorp ddiss at samba.org
Sun Nov 2 12:21:24 MST 2014


Also check for allocation failures.

Signed-off-by: David Disseldorp <ddiss at samba.org>
---
 source3/lib/eventlog/eventlog.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/source3/lib/eventlog/eventlog.c b/source3/lib/eventlog/eventlog.c
index 4c6767d..b63111e 100644
--- a/source3/lib/eventlog/eventlog.c
+++ b/source3/lib/eventlog/eventlog.c
@@ -73,7 +73,7 @@ char *elog_tdbname(TALLOC_CTX *ctx, const char *name )
 	char *file;
 	char *tdbname;
 
-	path = talloc_strdup(ctx, state_path("eventlog"));
+	path = state_path("eventlog");
 	if (!path) {
 		return NULL;
 	}
@@ -84,7 +84,7 @@ char *elog_tdbname(TALLOC_CTX *ctx, const char *name )
 		return NULL;
 	}
 
-	tdbname = talloc_asprintf(path, "%s/%s", state_path("eventlog"), file);
+	tdbname = talloc_asprintf(ctx, "%s/%s", path, file);
 	if (!tdbname) {
 		talloc_free(path);
 		return NULL;
@@ -372,8 +372,12 @@ ELOG_TDB *elog_open_tdb( const char *logname, bool force_clear, bool read_only )
 
 	/* make sure that the eventlog dir exists */
 
-	eventlogdir = state_path( "eventlog" );
+	eventlogdir = state_path("eventlog");
+	if (eventlogdir == NULL) {
+		return NULL;
+	}
 	ok = directory_create_or_exist(eventlogdir, 0755);
+	TALLOC_FREE(eventlogdir);
 	if (!ok) {
 		return NULL;
 	}
-- 
1.8.4.5



More information about the samba-technical mailing list