]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-tests: Return error on empty fake ctdbd configuration blocks
authorMartin Schwenke <martin@meltin.net>
Mon, 27 Jun 2022 00:34:13 +0000 (10:34 +1000)
committerAmitay Isaacs <amitay@samba.org>
Tue, 28 Jun 2022 09:24:31 +0000 (09:24 +0000)
These would be unintended errors.  The block should be omitted to keep
the default value.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/tests/src/fake_ctdbd.c

index 4d5c41f3fd29d756a9bc2268dbb298aa37426d50..ca6f5a24e9c1607b9eb21556ef83778e4d297ca5 100644 (file)
@@ -272,6 +272,10 @@ static bool nodemap_parse(struct node_map *node_map)
                node_map->num_nodes += 1;
        }
 
+       if (node_map->num_nodes == 0) {
+               goto fail;
+       }
+
        DEBUG(DEBUG_INFO, ("Parsing nodemap done\n"));
        return true;
 
@@ -521,6 +525,10 @@ static bool interfaces_parse(struct interface_map *iface_map)
                iface_map->num += 1;
        }
 
+       if (iface_map->num == 0) {
+               goto fail;
+       }
+
        DEBUG(DEBUG_INFO, ("Parsing interfaces done\n"));
        return true;
 
@@ -588,6 +596,10 @@ static bool vnnmap_parse(struct vnn_map *vnn_map)
                vnn_map->size += 1;
        }
 
+       if (vnn_map->size == 0) {
+               goto fail;
+       }
+
        DEBUG(DEBUG_INFO, ("Parsing vnnmap done\n"));
        return true;
 
@@ -606,8 +618,7 @@ static bool reclock_parse(struct ctdbd_context *ctdb)
        }
 
        if (line[0] == '\n') {
-               /* Recovery lock remains unset */
-               goto ok;
+               goto fail;
        }
 
        /* Get rid of pesky newline */
@@ -619,7 +630,7 @@ static bool reclock_parse(struct ctdbd_context *ctdb)
        if (ctdb->reclock == NULL) {
                goto fail;
        }
-ok:
+
        /* Swallow possible blank line following section.  Picky
         * compiler settings don't allow the return value to be
         * ignored, so make the compiler happy.
@@ -745,6 +756,10 @@ static bool dbmap_parse(struct database_map *db_map)
                DLIST_ADD_END(db_map->db, db);
        }
 
+       if (db_map->db == NULL) {
+               goto fail;
+       }
+
        DEBUG(DEBUG_INFO, ("Parsing dbmap done\n"));
        return true;
 
@@ -1046,7 +1061,7 @@ static bool public_ips_parse(struct ctdbd_context *ctdb,
 
        ctdb->known_ips = ipalloc_read_known_ips(ctdb, numnodes, false);
 
-       status = (ctdb->known_ips != NULL);
+       status = (ctdb->known_ips != NULL && ctdb->known_ips->num != 0);
 
        if (status) {
                D_INFO("Parsing public IPs done\n");
@@ -1139,6 +1154,10 @@ static bool control_failures_parse(struct ctdbd_context *ctdb)
                DLIST_ADD(ctdb->control_failures, failure);
        }
 
+       if (ctdb->control_failures == NULL) {
+               goto fail;
+       }
+
        D_INFO("Parsing fake control failures done\n");
        return true;