param: Add null checks for upcoming str_list_make changes
authorGarming Sam <garming@catalyst.net.nz>
Thu, 13 Mar 2014 20:30:52 +0000 (09:30 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 7 Jul 2014 21:32:35 +0000 (23:32 +0200)
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@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Nadezhda Ivanova <nivanova@samba.org>
lib/util/util_runcmd.c
lib/util/util_strlist.c

index c8547de694ab975d5792be090d2929d8cd4eba00..1ec717f548864433535f55f11c5ff4233c0425b8 100644 (file)
@@ -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) {
index d542e6f74f5eba2d3cdb07e94bf227fbd1363c3b..d0be917a5e3aa3aefc3d36572562ebfdf7b27f13 100644 (file)
@@ -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;