HomeClusterLabs Projects

Fix: tools: crm_node -i must initialize nodeid before passing pointer

Description

Fix: tools: crm_node -i must initialize nodeid before passing pointer

This is a regression introduced in 2.1.7 via a27f099.

Currently, crm_node -i passes a pointer to the uninitialized uint32_t
nodeid variable, to pcmkquery_node_info(). Since the pointer is
non-NULL, pcmk
query_node_info() dereferences it. Whatever garbage
value resides there gets passed as the ID to query.

The controller parses the node ID from the request as an int. If the
garbage value is greater than INT_MAX, it overflows to a negative int
value, and the controller (in handle_node_info_request()) defaults it to
0. In that case, there's no problem: we search for the local node name
instead of the garbage node ID.

If the garbage value is less than or equal to INT_MAX, we search for it
directly. We won't find a matching node unless one happens to exist with
that garbage node ID. In the case of no match, crm_node -i outputs "Node
is not known to cluster" instead of the local node's cluster-layer ID.

Thanks to Artur Novik for the report:
https://lists.clusterlabs.org/pipermail/users/2024-July/036270.html

Fixes T847

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>