[PATCH 06/27] pdb_tdb: don't leak state_path onto talloc tos

David Disseldorp ddiss at samba.org
Sun Nov 2 12:21:28 MST 2014


Also check for allocation failures.

Signed-off-by: David Disseldorp <ddiss at samba.org>
---
 source3/passdb/pdb_tdb.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/source3/passdb/pdb_tdb.c b/source3/passdb/pdb_tdb.c
index 9dd4451..0d31c47 100644
--- a/source3/passdb/pdb_tdb.c
+++ b/source3/passdb/pdb_tdb.c
@@ -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) {
-- 
1.8.4.5



More information about the samba-technical mailing list