1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

samlogon_cache: don't leak cache_path onto talloc tos

Also check for allocation failures.

Reported-by: Franz Pförtsch <franz.pfoertsch@brose.com>
Signed-off-by: David Disseldorp <ddiss@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
David Disseldorp 2014-10-06 18:21:17 +02:00 committed by Jeremy Allison
parent 21ed8058d2
commit 3c85465753

View File

@ -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;