summaryrefslogtreecommitdiff
path: root/source3/groupdb
diff options
context:
space:
mode:
authorDavid Disseldorp <ddiss@samba.org>2014-11-02 20:21:23 +0100
committerJeremy Allison <jra@samba.org>2014-11-03 23:46:04 +0100
commitb75d7ac9cbb0fef4daaac417dd63f2ef9e4701a8 (patch)
treee47a8b5064da97a5541f93e12580010989b0dbba /source3/groupdb
parent745a1c54b619caaaa80b4e8d4b4345f4d79a8c58 (diff)
downloadsamba-b75d7ac9cbb0fef4daaac417dd63f2ef9e4701a8.tar.gz
groupdb: 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>
Diffstat (limited to 'source3/groupdb')
-rw-r--r--source3/groupdb/mapping_tdb.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/source3/groupdb/mapping_tdb.c b/source3/groupdb/mapping_tdb.c
index cc397d964fd..ab79b687e16 100644
--- a/source3/groupdb/mapping_tdb.c
+++ b/source3/groupdb/mapping_tdb.c
@@ -46,24 +46,35 @@ static bool mapping_switch(const char *ldb_path);
****************************************************************************/
static bool init_group_mapping(void)
{
- const char *ldb_path;
+ char *tdb_path;
+ char *ldb_path;
if (db != NULL) {
return true;
}
- db = db_open(NULL, state_path("group_mapping.tdb"), 0,
+ tdb_path = state_path("group_mapping.tdb");
+ if (tdb_path == NULL) {
+ return false;
+ }
+ db = db_open(NULL, tdb_path, 0,
TDB_DEFAULT, O_RDWR|O_CREAT, 0600,
DBWRAP_LOCK_ORDER_1, DBWRAP_FLAG_NONE);
if (db == NULL) {
DEBUG(0, ("Failed to open group mapping database: %s\n",
strerror(errno)));
+ talloc_free(tdb_path);
return false;
}
ldb_path = state_path("group_mapping.ldb");
+ if (ldb_path == NULL) {
+ return false;
+ }
if (file_exist(ldb_path) && !mapping_switch(ldb_path)) {
- unlink(state_path("group_mapping.tdb"));
+ unlink(tdb_path);
+ talloc_free(tdb_path);
+ talloc_free(ldb_path);
return false;
} else {
@@ -114,6 +125,8 @@ static bool init_group_mapping(void)
}
#endif
}
+ talloc_free(tdb_path);
+ talloc_free(ldb_path);
return true;
}