File bsc#1239629-0001-Fix-pacemaker-attrd-prevent-segfault-if-a-peer-leave.patch of Package pacemaker.38493

From eaff3d57a5b4d56146820c1e3e532f23ff35b330 Mon Sep 17 00:00:00 2001
From: "Gao,Yan" <ygao@suse.com>
Date: Tue, 18 Mar 2025 16:57:25 +0100
Subject: [PATCH 1/8] Fix: pacemaker-attrd: prevent segfault if a peer leaves
 when its name is unknown yet

If nodes are not configured with names in corosync, when a node joins
the cluster, it takes a while for it to learn the names of all the other
online peers. Previously, if any of the peers happened to leave when its
`name` was unknown to us yet, pacemaker-attrd would trigger assertion in
`attrd_peer_remove()` and segfault in
`attrd_remove_peer_protocol_ver()`.
---
 daemons/attrd/attrd_corosync.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Index: pacemaker-2.1.5+20221208.a3f44794f/daemons/attrd/attrd_corosync.c
===================================================================
--- pacemaker-2.1.5+20221208.a3f44794f.orig/daemons/attrd/attrd_corosync.c
+++ pacemaker-2.1.5+20221208.a3f44794f/daemons/attrd/attrd_corosync.c
@@ -199,14 +199,16 @@ attrd_peer_change_cb(enum crm_status_typ
                 }
             } else {
                 // Remove all attribute values associated with lost nodes
-                attrd_peer_remove(peer->uname, false, "loss");
+                if (peer->uname != NULL) {
+                    attrd_peer_remove(peer->uname, false, "loss");
+                }
                 gone = true;
             }
             break;
     }
 
     // Remove votes from cluster nodes that leave, in case election in progress
-    if (gone && !is_remote) {
+    if (gone && !is_remote && peer->uname != NULL) {
         attrd_remove_voter(peer);
 
     // Ensure remote nodes that come up are in the remote node cache
openSUSE Build Service is sponsored by