[sheepdog] [PATCH] sheep: fix a little bug of is_master() in corosync.c

Hitoshi Mitake h.mitake at gmail.com
Wed Sep 26 15:19:48 CEST 2012


Current is_master() in sheep/cluster/corosync.c has a possibility of
reading array with invalid index. This patch fix the little bug.

Signed-off-by: Hitoshi Mitake <h.mitake at gmail.com>
---
 sheep/cluster/corosync.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/sheep/cluster/corosync.c b/sheep/cluster/corosync.c
index 3972013..e6a0083 100644
--- a/sheep/cluster/corosync.c
+++ b/sheep/cluster/corosync.c
@@ -253,9 +253,11 @@ static int is_master(struct cpg_node *node)
 
 	for (i = 0; i < SD_MAX_NODES; i++) {
 		if (!cpg_nodes[i].gone)
-			break;
+			goto eq_check;
 	}
+	return -1;
 
+eq_check:
 	if (cpg_node_equal(&cpg_nodes[i], n))
 		return i;
 	return -1;
-- 
1.7.5.1




More information about the sheepdog mailing list