From: Martin Schwenke Date: Mon, 27 Jun 2022 00:34:13 +0000 (+1000) Subject: ctdb-tests: Return error on empty fake ctdbd configuration blocks X-Git-Tag: tevent-0.13.0~219 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=05601cebc91e21a65837fcd8fc4635660f7d6ca1;p=thirdparty%2Fsamba.git ctdb-tests: Return error on empty fake ctdbd configuration blocks These would be unintended errors. The block should be omitted to keep the default value. Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- diff --git a/ctdb/tests/src/fake_ctdbd.c b/ctdb/tests/src/fake_ctdbd.c index 4d5c41f3fd2..ca6f5a24e9c 100644 --- a/ctdb/tests/src/fake_ctdbd.c +++ b/ctdb/tests/src/fake_ctdbd.c @@ -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;