summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Disseldorp <ddiss@samba.org>2014-11-02 20:21:24 +0100
committerJeremy Allison <jra@samba.org>2014-11-03 23:46:04 +0100
commita852116ab3d5e5ffd8f11d2b01c3fc17f8b6a086 (patch)
tree3c9f44c1fd7259ed2a4f510948ada475e873b8cd
parentb75d7ac9cbb0fef4daaac417dd63f2ef9e4701a8 (diff)
downloadsamba-a852116ab3d5e5ffd8f11d2b01c3fc17f8b6a086.tar.gz
samba-a852116ab3d5e5ffd8f11d2b01c3fc17f8b6a086.tar.xz
samba-a852116ab3d5e5ffd8f11d2b01c3fc17f8b6a086.zip
eventlog: don't leak state_path onto talloc tos
Also check for allocation failures. Signed-off-by: David Disseldorp <ddiss@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
-rw-r--r--source3/lib/eventlog/eventlog.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/source3/lib/eventlog/eventlog.c b/source3/lib/eventlog/eventlog.c
index 4c6767d550..b63111e8cc 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;
}