[PATCH 21/27] brlock: don't leak lock_path onto talloc tos

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


Also check for allocation failures.

Signed-off-by: David Disseldorp <ddiss at samba.org>
---
 source3/locking/brlock.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/source3/locking/brlock.c b/source3/locking/brlock.c
index 295e147..0e583f3 100644
--- a/source3/locking/brlock.c
+++ b/source3/locking/brlock.c
@@ -342,6 +342,7 @@ static NTSTATUS brl_lock_failed(files_struct *fsp,
 void brl_init(bool read_only)
 {
 	int tdb_flags;
+	char *db_path;
 
 	if (brlock_db) {
 		return;
@@ -358,15 +359,23 @@ void brl_init(bool read_only)
 		tdb_flags |= TDB_SEQNUM;
 	}
 
-	brlock_db = db_open(NULL, lock_path("brlock.tdb"),
+	db_path = lock_path("brlock.tdb");
+	if (db_path == NULL) {
+		DEBUG(0, ("out of memory!\n"));
+		return;
+	}
+
+	brlock_db = db_open(NULL, db_path,
 			    SMB_OPEN_DATABASE_TDB_HASH_SIZE, tdb_flags,
 			    read_only?O_RDONLY:(O_RDWR|O_CREAT), 0644,
 			    DBWRAP_LOCK_ORDER_2, DBWRAP_FLAG_NONE);
 	if (!brlock_db) {
 		DEBUG(0,("Failed to open byte range locking database %s\n",
-			lock_path("brlock.tdb")));
+			 db_path));
+		TALLOC_FREE(db_path);
 		return;
 	}
+	TALLOC_FREE(db_path);
 }
 
 /****************************************************************************
-- 
1.8.4.5



More information about the samba-technical mailing list