From 2fb694df23616c660000f3bfa471927163c0f9ff Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 15 Jan 2009 23:43:00 +0100 Subject: s3:vfs_xattr_tdb: don't leak state_path() to talloc_tos in xattr_tdb_init(). Michael --- source3/modules/vfs_xattr_tdb.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_xattr_tdb.c b/source3/modules/vfs_xattr_tdb.c index c4806e26c3..44bfffb94e 100644 --- a/source3/modules/vfs_xattr_tdb.c +++ b/source3/modules/vfs_xattr_tdb.c @@ -574,15 +574,18 @@ static bool xattr_tdb_init(int snum, struct db_context **p_db) { struct db_context *db; const char *dbname; + char *def_dbname; - dbname = lp_parm_const_string(snum, "xattr_tdb", "file", - state_path("xattr.tdb")); - - if (dbname == NULL) { + def_dbname = state_path("xattr.tdb"); + if (def_dbname == NULL) { errno = ENOSYS; return false; } + dbname = lp_parm_const_string(snum, "xattr_tdb", "file", def_dbname); + + /* now we know dbname is not NULL */ + become_root(); db = db_open(NULL, dbname, 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600); unbecome_root(); @@ -593,10 +596,12 @@ static bool xattr_tdb_init(int snum, struct db_context **p_db) #else errno = ENOSYS; #endif + TALLOC_FREE(def_dbname); return false; } *p_db = db; + TALLOC_FREE(def_dbname); return true; } -- cgit