pdb_tdb: don't leak state_path onto talloc tos
authorDavid Disseldorp <ddiss@samba.org>
Sun, 2 Nov 2014 19:21:28 +0000 (20:21 +0100)
committerJeremy Allison <jra@samba.org>
Mon, 3 Nov 2014 22:46:04 +0000 (23:46 +0100)
Also check for allocation failures.

Signed-off-by: David Disseldorp <ddiss@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/passdb/pdb_tdb.c

index 9dd445103df6361e8856df05a1e06b019b421d79..0d31c47bfa61e3e71ac8a0824d64d122e327d5cc 100644 (file)
@@ -329,15 +329,21 @@ static bool tdbsam_upgrade_next_rid(struct db_context *db)
        uint32 rid;
        bool ok = false;
        NTSTATUS status;
+       char *db_path;
 
        status = dbwrap_fetch_uint32_bystring(db, NEXT_RID_STRING, &rid);
        if (NT_STATUS_IS_OK(status)) {
                return true;
        }
 
-       tdb = tdb_open_log(state_path("winbindd_idmap.tdb"), 0,
-                          TDB_DEFAULT, O_RDONLY, 0644);
+       db_path = state_path("winbindd_idmap.tdb");
+       if (db_path == NULL) {
+               return false;
+       }
 
+       tdb = tdb_open_log(db_path, 0,
+                          TDB_DEFAULT, O_RDONLY, 0644);
+       TALLOC_FREE(db_path);
        if (tdb) {
                ok = tdb_fetch_uint32(tdb, "RID_COUNTER", &rid);
                if (!ok) {