diff options
author | David Disseldorp <ddiss@samba.org> | 2014-11-02 20:21:46 +0100 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2014-11-03 23:46:05 +0100 |
commit | d3cd60d660a4a8ef03689c0b66ed730e444f84cc (patch) | |
tree | e40ce87e06beb1d2a9cb221b0e6b884279a9b095 | |
parent | 49fe698fe9a794938725efd32b14c6bce95e1ef7 (diff) | |
download | samba-d3cd60d660a4a8ef03689c0b66ed730e444f84cc.tar.gz samba-d3cd60d660a4a8ef03689c0b66ed730e444f84cc.tar.xz samba-d3cd60d660a4a8ef03689c0b66ed730e444f84cc.zip |
printer_list: don't leak lock_path onto talloc tos
Also check for allocation failures.
Signed-off-by: David Disseldorp <ddiss@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
-rw-r--r-- | source3/printing/printer_list.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/source3/printing/printer_list.c b/source3/printing/printer_list.c index 7868874a6a..9b20dc19ad 100644 --- a/source3/printing/printer_list.c +++ b/source3/printing/printer_list.c @@ -24,7 +24,6 @@ #include "util_tdb.h" #include "printer_list.h" -#define PL_DB_NAME() lock_path("printer_list.tdb") #define PL_KEY_PREFIX "PRINTERLIST/PRN/" #define PL_KEY_FORMAT PL_KEY_PREFIX"%s" #define PL_TIMESTAMP_KEY "PRINTERLIST/GLOBAL/LAST_REFRESH" @@ -34,14 +33,22 @@ static struct db_context *get_printer_list_db(void) { static struct db_context *db; + char *db_path; if (db != NULL) { return db; } - db = db_open(NULL, PL_DB_NAME(), 0, + + db_path = lock_path("printer_list.tdb"); + if (db_path == NULL) { + return NULL; + } + + db = db_open(NULL, db_path, 0, TDB_DEFAULT|TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH, O_RDWR|O_CREAT, 0644, DBWRAP_LOCK_ORDER_1, DBWRAP_FLAG_NONE); + TALLOC_FREE(db_path); return db; } |