[PATCH 06/37] param: Add null checks for upcoming str_list_make changes

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


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

In changing str_list_make to str_list_make_v3, the list can be NULL.
These are some additional checks to try to avoid any problems.

Where lists are dealt with, they typically check both if the list is
empty or the list is NULL.

Change-Id: I9012c31dbd9832ce877728bcb3346616ba64c4c5
Signed-off-by: Garming Sam <garming at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
---
 lib/util/util_runcmd.c  | 4 ++++
 lib/util/util_strlist.c | 4 ++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/util/util_runcmd.c b/lib/util/util_runcmd.c
index c8547de..1ec717f 100644
--- a/lib/util/util_runcmd.c
+++ b/lib/util/util_runcmd.c
@@ -80,6 +80,10 @@ struct tevent_req *samba_runcmd_send(TALLOC_CTX *mem_ctx,
 	char **argv;
 	va_list ap;
 
+	if (argv0 == NULL) {
+		return NULL;
+	}
+
 	req = tevent_req_create(mem_ctx, &state,
 				struct samba_runcmd_state);
 	if (req == NULL) {
diff --git a/lib/util/util_strlist.c b/lib/util/util_strlist.c
index d542e6f..d0be917 100644
--- a/lib/util/util_strlist.c
+++ b/lib/util/util_strlist.c
@@ -330,7 +330,7 @@ _PUBLIC_ bool str_list_check(const char **list, const char *s)
 {
 	int i;
 
-	for (i=0;list[i];i++) {
+	for (i=0; list != NULL && list[i] != NULL; i++) {
 		if (strcmp(list[i], s) == 0) return true;
 	}
 	return false;
@@ -343,7 +343,7 @@ _PUBLIC_ bool str_list_check_ci(const char **list, const char *s)
 {
 	int i;
 
-	for (i=0;list[i];i++) {
+	for (i=0; list != NULL && list[i] != NULL; i++) {
 		if (strcasecmp(list[i], s) == 0) return true;
 	}
 	return false;
-- 
1.9.3



More information about the samba-technical mailing list