From 3c854657531ac73ce5e3148e35844e3c8130fe37 Mon Sep 17 00:00:00 2001 From: David Disseldorp Date: Mon, 6 Oct 2014 18:21:17 +0200 Subject: samlogon_cache: don't leak cache_path onto talloc tos MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also check for allocation failures. Reported-by: Franz Pförtsch Signed-off-by: David Disseldorp Reviewed-by: Jeremy Allison --- source3/libsmb/samlogon_cache.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'source3/libsmb/samlogon_cache.c') diff --git a/source3/libsmb/samlogon_cache.c b/source3/libsmb/samlogon_cache.c index 0a157d48463..1f1ab1d46e8 100644 --- a/source3/libsmb/samlogon_cache.c +++ b/source3/libsmb/samlogon_cache.c @@ -38,7 +38,7 @@ static TDB_CONTEXT *netsamlogon_tdb = NULL; bool netsamlogon_cache_init(void) { bool first_try = true; - const char *path = NULL; + char *path = NULL; int ret; struct tdb_context *tdb; @@ -47,6 +47,9 @@ bool netsamlogon_cache_init(void) } path = cache_path(NETSAMLOGON_TDB); + if (path == NULL) { + return false; + } again: tdb = tdb_open_log(path, 0, TDB_DEFAULT|TDB_INCOMPATIBLE_HASH, O_RDWR | O_CREAT, 0600); @@ -63,10 +66,12 @@ again: } netsamlogon_tdb = tdb; + talloc_free(path); return true; clear: if (!first_try) { + talloc_free(path); return false; } first_try = false; -- cgit v1.2.1