diff options
author | David Disseldorp <ddiss@samba.org> | 2014-10-06 18:21:13 +0200 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2014-10-06 19:18:05 +0200 |
commit | e8ee9bb66e765433e94f03d46ccb66459bb5fc3f (patch) | |
tree | f5074cc6aecf143edfab7e37646d0a72050e92fc /source3/lib/gencache.c | |
parent | e4c27cb4bb7e2caa0296c79746d0eff8d34036fa (diff) | |
download | samba-e8ee9bb66e765433e94f03d46ccb66459bb5fc3f.tar.gz samba-e8ee9bb66e765433e94f03d46ccb66459bb5fc3f.tar.xz samba-e8ee9bb66e765433e94f03d46ccb66459bb5fc3f.zip |
gencache: 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>
Diffstat (limited to 'source3/lib/gencache.c')
-rw-r--r-- | source3/lib/gencache.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/source3/lib/gencache.c b/source3/lib/gencache.c index 3e67d9ebe7..3192b454b8 100644 --- a/source3/lib/gencache.c +++ b/source3/lib/gencache.c @@ -65,6 +65,9 @@ static bool gencache_init(void) if (cache) return True; cache_fname = cache_path("gencache.tdb"); + if (cache_fname == NULL) { + return false; + } DEBUG(5, ("Opening cache file at %s\n", cache_fname)); @@ -101,6 +104,7 @@ static bool gencache_init(void) DEBUG(5, ("gencache_init: Opening cache file %s read-only.\n", cache_fname)); } } + TALLOC_FREE(cache_fname); if (!cache) { DEBUG(5, ("Attempt to open gencache.tdb has failed.\n")); @@ -108,6 +112,11 @@ static bool gencache_init(void) } cache_fname = lock_path("gencache_notrans.tdb"); + if (cache_fname == NULL) { + tdb_close(cache); + cache = NULL; + return false; + } DEBUG(5, ("Opening cache file at %s\n", cache_fname)); @@ -120,10 +129,12 @@ static bool gencache_init(void) if (cache_notrans == NULL) { DEBUG(5, ("Opening %s failed: %s\n", cache_fname, strerror(errno))); + TALLOC_FREE(cache_fname); tdb_close(cache); cache = NULL; return false; } + TALLOC_FREE(cache_fname); return True; } |