s3-printing: precreate DriverStore directories patch

Andreas Schneider asn at samba.org
Mon Jul 31 08:10:53 UTC 2017


On Wednesday, 26 July 2017 18:39:09 CEST Jeremy Allison via samba-technical 
wrote:
> Guenther and Andreas - there are missing
> NULL return checks on the calls to
> state_path() in this patch.
> 
> (state_path() returns a talloc'ed string, which
> can return NULL).
> 
> Can you add the checks in and post for review
> please ?

Yes, see attached patch.


Thanks,


	Andreas

-- 
Andreas Schneider                   GPG-ID: CC014E3D
Samba Team                             asn at samba.org
www.samba.org
-------------- next part --------------
>From 2300a753126f44896556f641db87ad1e27523743 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Mon, 31 Jul 2017 10:09:52 +0200
Subject: [PATCH] s3:printing: Add NULL check for state_path()

Signed-off-by: Andreas Schneider <asn at samba.org>
---
 source3/printing/nt_printing.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index 0a0d3f75c69..932d4d76df0 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -153,20 +153,37 @@ static bool print_driver_directories_init(void)
 	}
 
 	driver_path = state_path("DriverStore");
+	if (driver_path == NULL) {
+		talloc_free(mem_ctx);
+		return false;
+	}
+
 	ok = directory_create_or_exist(driver_path, 0755);
 	if (!ok) {
 		DEBUG(1,("failed to create path %s\n", driver_path));
 		talloc_free(mem_ctx);
 		return false;
 	}
+
 	driver_path = state_path("DriverStore/FileRepository");
+	if (driver_path == NULL) {
+		talloc_free(mem_ctx);
+		return false;
+	}
+
 	ok = directory_create_or_exist(driver_path, 0755);
 	if (!ok) {
 		DEBUG(1,("failed to create path %s\n", driver_path));
 		talloc_free(mem_ctx);
 		return false;
 	}
+
 	driver_path = state_path("DriverStore/Temp");
+	if (driver_path == NULL) {
+		talloc_free(mem_ctx);
+		return false;
+	}
+
 	ok = directory_create_or_exist(driver_path, 0755);
 	if (!ok) {
 		DEBUG(1,("failed to create path %s\n", driver_path));
-- 
2.13.3



More information about the samba-technical mailing list