From d6792eca3c8cc4356d1e3a64161c8a0e5f8ff9d4 Mon Sep 17 00:00:00 2001 From: David Disseldorp Date: Sun, 2 Nov 2014 20:21:42 +0100 Subject: serverid: don't leak lock_path onto talloc tos Also check for allocation failures. Signed-off-by: David Disseldorp Reviewed-by: Jeremy Allison --- source3/lib/serverid.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/source3/lib/serverid.c b/source3/lib/serverid.c index ee479b4e68..f5e0937224 100644 --- a/source3/lib/serverid.c +++ b/source3/lib/serverid.c @@ -42,14 +42,22 @@ struct serverid_data { static struct db_context *serverid_db(void) { static struct db_context *db; + char *db_path; if (db != NULL) { return db; } - db = db_open(NULL, lock_path("serverid.tdb"), 0, + + db_path = lock_path("serverid.tdb"); + if (db_path == NULL) { + return NULL; + } + + db = db_open(NULL, db_path, 0, TDB_DEFAULT|TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH, O_RDWR|O_CREAT, 0644, DBWRAP_LOCK_ORDER_2, DBWRAP_FLAG_NONE); + TALLOC_FREE(db_path); return db; } -- cgit