diff options
author | Michael Adam <obnox@samba.org> | 2009-01-15 23:43:00 +0100 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2009-01-16 01:02:21 +0100 |
commit | 2fb694df23616c660000f3bfa471927163c0f9ff (patch) | |
tree | 6ad397c5309d67f13ee7404b06b5963694d55e47 | |
parent | 26e5e4f6fd07893d914ac9a397669b6b4097e0be (diff) | |
download | samba-2fb694df23616c660000f3bfa471927163c0f9ff.tar.gz samba-2fb694df23616c660000f3bfa471927163c0f9ff.tar.bz2 samba-2fb694df23616c660000f3bfa471927163c0f9ff.zip |
s3:vfs_xattr_tdb: don't leak state_path() to talloc_tos in xattr_tdb_init().
Michael
-rw-r--r-- | source3/modules/vfs_xattr_tdb.c | 13 |
1 files changed, 9 insertions, 4 deletions
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; } |