HomeClusterLabs Projects

Refactor: based: Fix use-after-free in cib_process_command()

Description

Refactor: based: Fix use-after-free in cib_process_command()

activateCibXml() frees the_cib on success. current_cib holds a pointer
to the_cib. So the crm_trace() called crm_element_value() on a
freed-but-not-nulled XML node.

Also improve the message and log at error level on failure.

Finally, drop the local current_cib variable completely. It only
marginally improves readability, while it makes the function more error-
prone. We risk forgetting to update the current_cib pointer when we
update or free the_cib, as we've seen here.

There are more improvements we could (and should) make to tracing and to
the use and documentation of activateCibXml(), but those can wait.

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

Details

Provenance
nrwahl2Authored on May 26 2023, 5:13 PM
Parents
rPf29048d52eeb: Refactor: based: Drop needs_forward argument from parse_peer_options()
Branches
Unknown
Tags
Unknown