[PATCH 05/37] param: pre-emptively correct use of str_list_make_v3 in lib/param

abartlet at samba.org abartlet at samba.org
Fri Jun 20 05:47:27 MDT 2014


From: Garming Sam <garming at catalyst.net.nz>

lib/param uses str_list_make, while, s3 uses str_list_make_v3. These
differ slightly and should be made the same.

Notably it returns NULL when given a null or empty string

Also, includes the null check in s3 code to be consistent for merging
this section of code later on.

Change-Id: Ib543a5a5307e06989621ea16bfe87e315d66a7ef
Signed-off-by: Garming Sam <garming at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
---
 lib/param/loadparm.c     | 4 ++++
 source3/param/loadparm.c | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/lib/param/loadparm.c b/lib/param/loadparm.c
index 836995a..bec706e 100644
--- a/lib/param/loadparm.c
+++ b/lib/param/loadparm.c
@@ -1470,6 +1470,10 @@ bool set_variable_helper(TALLOC_CTX *mem_ctx, int parmnum, void *parm_ptr,
 		{
 			char **new_list = str_list_make(mem_ctx,
 							pszParmValue, NULL);
+			if (new_list == NULL) {
+				break;
+			}
+
 			for (i=0; new_list[i]; i++) {
 				if (*(const char ***)parm_ptr != NULL &&
 				    new_list[i][0] == '+' &&
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index c9bfe1e..ec168e9 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -2688,6 +2688,10 @@ bool lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue
 		{
 			char **new_list = str_list_make_v3(mem_ctx,
 							pszParmValue, NULL);
+			if (new_list == NULL) {
+				break;
+			}
+
 			for (i=0; new_list[i]; i++) {
 				if (*(const char ***)parm_ptr != NULL &&
 				    new_list[i][0] == '+' &&
-- 
1.9.3



More information about the samba-technical mailing list