Просмотр исходного кода

fixe a bug in cpg where get_group() will return the wrong group
info structure if there is a hash collision.


git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1199 fd59a12c-fef9-0310-b244-a6a79926bd2f

Patrick Caulfield 19 лет назад
Родитель
Сommit
1141aab7b3
1 измененных файлов с 5 добавлено и 2 удалено
  1. 5 2
      exec/cpg.c

+ 5 - 2
exec/cpg.c

@@ -464,12 +464,15 @@ static struct group_info *get_group(mar_cpg_name_t *name)
 {
 {
 	struct list_head *iter;
 	struct list_head *iter;
 	struct group_info *gi = NULL;
 	struct group_info *gi = NULL;
+	struct group_info *itergi;
 	uint32_t hash = jhash(name->value, name->length, 0) % GROUP_HASH_SIZE;
 	uint32_t hash = jhash(name->value, name->length, 0) % GROUP_HASH_SIZE;
 
 
 	for (iter = group_lists[hash].next; iter != &group_lists[hash]; iter = iter->next) {
 	for (iter = group_lists[hash].next; iter != &group_lists[hash]; iter = iter->next) {
-		gi = list_entry(iter, struct group_info, list);
-		if (memcmp(gi->group_name.value, name->value, name->length) == 0)
+		itergi = list_entry(iter, struct group_info, list);
+		if (memcmp(itergi->group_name.value, name->value, name->length) == 0) {
+			gi = itergi;
 			break;
 			break;
+		}
 	}
 	}
 
 
 	if (!gi) {
 	if (!gi) {