[Openais] [PATCH] CPG: Fix lookup bug when hashes collide

Patrick Caulfield pcaulfie at redhat.com
Thu Aug 10 06:28:44 PDT 2006


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

This is a bad bug that needs fixing in whitetank as well as trunk IMHO.

-- 

patrick


Index: exec/cpg.c
===================================================================
--- exec/cpg.c	(revision 1198)
+++ exec/cpg.c	(working copy)
@@ -464,12 +464,15 @@
 {
 	struct list_head *iter;
 	struct group_info *gi = NULL;
+	struct group_info *itergi;
 	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) {
-		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;
+		}
 	}

 	if (!gi) {



More information about the Openais mailing list