File bsc#1219323-0001-Fix-libcrmcommon-avoid-file-descriptor-leak-in-IPC-c.patch of Package pacemaker.38493
From 47d6055bf418f7049fc716745be95374f465eb77 Mon Sep 17 00:00:00 2001
From: "Gao,Yan" <ygao@suse.com>
Date: Wed, 7 Feb 2024 11:21:23 +0100
Subject: [PATCH] Fix: libcrmcommon: avoid file descriptor leak in IPC client
with async connection
Previously if qb_ipcc_connect_async() succeeded but the following poll()
failed, the file descriptor would leak.
In that case, given that disconnect function is not registered yet,
qb_ipcc_disconnect() won't clean up the socket. In any case, call
qb_ipcc_connect_continue() here so that it may fail and do the cleanup
for us.
Issue introduced in 2.1.3 by 4b60aa100.
---
lib/common/ipc_client.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/lib/common/ipc_client.c b/lib/common/ipc_client.c
index 4635d38d8..df6697cee 100644
--- a/lib/common/ipc_client.c
+++ b/lib/common/ipc_client.c
@@ -1623,13 +1623,17 @@ pcmk__ipc_is_authentic_process_active(const char *name, uid_t refuid,
do {
poll_rc = poll(&pollfd, 1, 2000);
} while ((poll_rc == -1) && (errno == EINTR));
- if ((poll_rc <= 0) || (qb_ipcc_connect_continue(c) != 0)) {
+
+ /* If poll() failed, given that disconnect function is not registered yet,
+ * qb_ipcc_disconnect() won't clean up the socket. In any case, call
+ * qb_ipcc_connect_continue() here so that it may fail and do the cleanup
+ * for us.
+ */
+ if (qb_ipcc_connect_continue(c) != 0) {
crm_info("Could not connect to %s IPC: %s", name,
(poll_rc == 0)?"timeout":strerror(errno));
rc = pcmk_rc_ipc_unresponsive;
- if (poll_rc > 0) {
- c = NULL; // qb_ipcc_connect_continue cleaned up for us
- }
+ c = NULL; // qb_ipcc_connect_continue cleaned up for us
goto bail;
}
#endif
--
2.35.3