From 58b18e23e9de221e80fe978366ef05b65312919b Mon Sep 17 00:00:00 2001 From: David Disseldorp Date: Mon, 6 Oct 2014 18:21:15 +0200 Subject: printing: don't leak cache_path onto talloc tos MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also check for allocation failures. Reported-by: Franz Pförtsch Signed-off-by: David Disseldorp Reviewed-by: Jeremy Allison --- source3/printing/printing.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'source3/printing/printing.c') diff --git a/source3/printing/printing.c b/source3/printing/printing.c index dcfd2a2dc5e..d8b619162e9 100644 --- a/source3/printing/printing.c +++ b/source3/printing/printing.c @@ -198,17 +198,28 @@ bool print_backend_init(struct messaging_context *msg_ctx) int services = lp_numservices(); int snum; bool ok; + char *print_cache_path; if (!printer_list_parent_init()) { return false; } - ok = directory_create_or_exist(cache_path("printing"), 0755); + print_cache_path = cache_path("printing"); + if (print_cache_path == NULL) { + return false; + } + ok = directory_create_or_exist(print_cache_path, 0755); + TALLOC_FREE(print_cache_path); if (!ok) { return false; } - unlink(cache_path("printing.tdb")); + print_cache_path = cache_path("printing.tdb"); + if (print_cache_path == NULL) { + return false; + } + unlink(print_cache_path); + TALLOC_FREE(print_cache_path); /* handle a Samba upgrade */ -- cgit v1.2.1