[PATCH 24/27] printer_list: don't leak lock_path onto talloc tos
David Disseldorp
ddiss at samba.org
Sun Nov 2 12:21:46 MST 2014
Also check for allocation failures.
Signed-off-by: David Disseldorp <ddiss at samba.org>
---
source3/printing/printer_list.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/source3/printing/printer_list.c b/source3/printing/printer_list.c
index 7868874..9b20dc1 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;
}
--
1.8.4.5
More information about the samba-technical
mailing list