sharesec: don't leak state_path onto talloc tos
authorDavid Disseldorp <ddiss@samba.org>
Sun, 2 Nov 2014 19:21:25 +0000 (20:21 +0100)
committerJeremy Allison <jra@samba.org>
Mon, 3 Nov 2014 22:46:04 +0000 (23:46 +0100)
Also check for allocation failures.

Signed-off-by: David Disseldorp <ddiss@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/lib/sharesec.c

index 095c851825ed83ef3bf8adae980746e81c1d1e96..e9a3eae91784abe64512ea32942984dfd0ec3943 100644 (file)
@@ -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)) {