From: Martin Schwenke Date: Thu, 30 Jul 2020 01:57:51 +0000 (+1000) Subject: ctdb-recoverd: Fix node_pnn check and assignment of nodemap into array X-Git-Tag: samba-4.11.14~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=238564c74957f5488ebdbc5d779726e83e41b1c7;p=thirdparty%2Fsamba.git ctdb-recoverd: Fix node_pnn check and assignment of nodemap into array This array is indexed by the same index as nodemap, not the PNN. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14466 Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs (cherry picked from commit 368c83bfe3bbfff568d14f65e7b1ffa41d5349ac) --- diff --git a/ctdb/server/ctdb_recoverd.c b/ctdb/server/ctdb_recoverd.c index f0c5efd5b6d..9fd1debbcf7 100644 --- a/ctdb/server/ctdb_recoverd.c +++ b/ctdb/server/ctdb_recoverd.c @@ -2237,13 +2237,21 @@ static void async_getnodemap_callback(struct ctdb_context *ctdb, struct remote_nodemaps_state *state = (struct remote_nodemaps_state *)callback_data; struct ctdb_node_map_old **remote_nodemaps = state->remote_nodemaps; + struct ctdb_node_map_old *nodemap = state->rec->nodemap; + size_t i; - if (node_pnn >= ctdb->num_nodes) { - DBG_ERR("Invalid PNN\n"); + for (i = 0; i < nodemap->num; i++) { + if (nodemap->nodes[i].pnn == node_pnn) { + break; + } + } + + if (i >= nodemap->num) { + DBG_ERR("Invalid PNN %"PRIu32"\n", node_pnn); return; } - remote_nodemaps[node_pnn] = (struct ctdb_node_map_old *)talloc_steal( + remote_nodemaps[i] = (struct ctdb_node_map_old *)talloc_steal( remote_nodemaps, outdata.dptr); }