diff options
author | David Disseldorp <ddiss@samba.org> | 2014-11-02 20:21:25 +0100 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2014-11-03 23:46:04 +0100 |
commit | f62d9080ad143a35c7825f187c8f7eea9def9810 (patch) | |
tree | 5830fe867e42ced46ca14f29f3e10d9ff1a4fb8d /source3/lib/sharesec.c | |
parent | a852116ab3d5e5ffd8f11d2b01c3fc17f8b6a086 (diff) | |
download | samba-f62d9080ad143a35c7825f187c8f7eea9def9810.tar.gz samba-f62d9080ad143a35c7825f187c8f7eea9def9810.tar.xz samba-f62d9080ad143a35c7825f187c8f7eea9def9810.zip |
sharesec: don't leak state_path onto talloc tos
Also check for allocation failures.
Signed-off-by: David Disseldorp <ddiss@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/lib/sharesec.c')
-rw-r--r-- | source3/lib/sharesec.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/source3/lib/sharesec.c b/source3/lib/sharesec.c index 095c851825..e9a3eae917 100644 --- a/source3/lib/sharesec.c +++ b/source3/lib/sharesec.c @@ -142,19 +142,27 @@ bool share_info_db_init(void) int32 vers_id = 0; bool upgrade_ok = true; NTSTATUS status; + char *db_path; if (share_db != NULL) { return True; } - share_db = db_open(NULL, state_path("share_info.tdb"), 0, + db_path = state_path("share_info.tdb"); + if (db_path == NULL) { + return false; + } + + share_db = db_open(NULL, db_path, 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600, DBWRAP_LOCK_ORDER_1, DBWRAP_FLAG_NONE); if (share_db == NULL) { DEBUG(0,("Failed to open share info database %s (%s)\n", - state_path("share_info.tdb"), strerror(errno) )); + db_path, strerror(errno))); + TALLOC_FREE(db_path); return False; } + TALLOC_FREE(db_path); status = dbwrap_fetch_int32_bystring(share_db, vstring, &vers_id); if (!NT_STATUS_IS_OK(status)) { |