libqb/bug-947341_libqb-ipc-fd-memory-leaks.patch
Yan Gao 581ca04095 Accepting request 337267 from home:yan_gao:branches:network:ha-clustering:Factory:Test
- ipc: Prevent fd and memory leaks in handle_new_connection() (bsc#947341)
 * bug-947341_libqb-ipc-fd-memory-leaks.patch

- log: don't call dlopen inside dl_iterate_phdr()
- ipc: Don't send the dispatch_del() function a closed fd
- Upstream version cs: 1a7ea3b8d8bf9d5ffbbfdc785ace2b81e9f2356d

OBS-URL: https://build.opensuse.org/request/show/337267
OBS-URL: https://build.opensuse.org/package/show/network:ha-clustering:Factory/libqb?expand=0&rev=69
2015-10-09 11:34:33 +00:00

31 lines
911 B
Diff

commit f5fd0c950ce1bf19fd5186fd2b1f2cc67f5de3ec
Author: Gao,Yan <ygao@suse.com>
Date: Tue Oct 6 17:48:05 2015 +0200
Fix: ipc: Prevent fd and memory leaks in handle_new_connection()
In handle_new_connection(), connection_accept() could fail, which would
leave the state of the connection inactive. Previously, in this case,
the socket and the allocated qb_ipcs_connection would be leaked.
diff --git a/lib/ipc_setup.c b/lib/ipc_setup.c
index 28a0ddc..06257c1 100644
--- a/lib/ipc_setup.c
+++ b/lib/ipc_setup.c
@@ -556,7 +556,14 @@ send_response:
"Error in connection setup (%s)",
c->description);
}
- qb_ipcs_disconnect(c);
+
+ if (c->state == QB_IPCS_CONNECTION_INACTIVE) {
+ /* This removes the initial alloc ref */
+ qb_ipcs_connection_unref(c);
+ qb_ipcc_us_sock_close(sock);
+ } else {
+ qb_ipcs_disconnect(c);
+ }
}
return res;
}