Skip to contentSkip to conversation

LVM2 ./WHATS_NEW daemons/clvmd/clvmd-cman.c

PATCH [email protected] 1 participant 1 message Mar 25, 2008

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: ccaulfield at sourceware.org 2008-03-25 10:41:59

Modified files:
. : WHATS_NEW
daemons/clvmd : clvmd-cman.c

Log message:
When reallocating the node IDs array, make it bigger rather than smaller!

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.804&r2=1.805
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd-cman.c.diff?cvsroot=lvm2&r1=1.20&r2=1.21

WHATS_NEW +1 -0
@@ -1,5 +1,6 @@
 Version 2.02.34 -
 ===================================
+  clvmd no longer crashes if it sees nodeids over 50.
   Fix potential deadlock in clvmd thread handling.
   Refactor text format initialisation into _init_text_import.
   Escape double quotes and backslashes in external metadata and config data.
daemons/clvmd/clvmd-cman.c +5 -2
@@ -241,7 +241,7 @@
 
 	if (nodeid >= max_updown_nodes) {
 	        int new_size = nodeid + 10;
-		int *new_updown = realloc(node_updown, new_size);
+		int *new_updown = realloc(node_updown, sizeof(int) * new_size);
 
 		if (new_updown) {
 			node_updown = new_updown;
@@ -326,7 +326,10 @@
 	}
 
 	if (node_updown == NULL) {
-		size_t buf_len = sizeof(int) * max(num_nodes, max_updown_nodes);
+		size_t buf_len;
+		if (num_nodes > max_updown_nodes)
+			max_updown_nodes = num_nodes;
+		buf_len = sizeof(int) * max_updown_nodes;
 		node_updown = malloc(buf_len);
 		if (node_updown)
 			memset(node_updown, 0, buf_len);