[Cluster-devel] [PATCH] cman: fix handling of transport="xxx" in cman/totem preconfig
Fabio M. Di Nitto
fdinitto at redhat.com
Mon Aug 8 09:37:45 UTC 2011
and address a memory corruption when broadcast="" is set.
Resolves: rhbz#695795
Signed-off-by: Fabio M. Di Nitto <fdinitto at redhat.com>
---
cman/daemon/cman-preconfig.c | 12 +++++++++---
1 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/cman/daemon/cman-preconfig.c b/cman/daemon/cman-preconfig.c
index 070761e..0f5f937 100644
--- a/cman/daemon/cman-preconfig.c
+++ b/cman/daemon/cman-preconfig.c
@@ -283,6 +283,7 @@ static int add_ifaddr(struct objdb_iface_ver0 *objdb, char *mcast, char *ifaddr,
hdb_handle_t interface_object_handle;
struct sockaddr_storage if_addr, localhost, mcast_addr;
char tmp[132];
+ char *transportstr;
int ret = 0;
const char *tx_mech_to_str[] = {
[TX_MECH_UDP] = "udp",
@@ -309,11 +310,17 @@ static int add_ifaddr(struct objdb_iface_ver0 *objdb, char *mcast, char *ifaddr,
if (objdb->object_find_next(find_handle, &totem_object_handle)) {
objdb->object_create(OBJECT_PARENT_HANDLE, &totem_object_handle,
"totem", strlen("totem"));
- objdb->object_key_create_typed(totem_object_handle, "transport",
- tx_mech_to_str[transport], strlen(tx_mech_to_str[transport]) + 1, OBJDB_VALUETYPE_STRING);
}
objdb->object_find_destroy(find_handle);
+ if (objdb_get_string(objdb, totem_object_handle, "transport", &transportstr)) {
+ objdb->object_key_create_typed(totem_object_handle, "transport",
+ tx_mech_to_str[transport], strlen(tx_mech_to_str[transport]) + 1, OBJDB_VALUETYPE_STRING);
+ } else {
+ sprintf(error_reason, "Transport should not be specified within <totem .../>, use <cman transport=\"...\" /> instead");
+ return -1;
+ }
+
if (objdb->object_create(totem_object_handle, &interface_object_handle,
"interface", strlen("interface")) == 0) {
struct sockaddr_in *in = (struct sockaddr_in *)&if_addr;
@@ -709,7 +716,6 @@ static int get_nodename(struct objdb_iface_ver0 *objdb)
return -1;
transport = TX_MECH_UDPB;
}
- free(str);
}
/* Check for transport */
--
1.7.4.4
More information about the Cluster-devel
mailing list