]> sourceware.org Git - lvm2.git/commitdiff
Fix hash lookup segfault when keys compared are different lengths.
authorAlasdair Kergon <agk@redhat.com>
Tue, 3 Nov 2009 00:45:35 +0000 (00:45 +0000)
committerAlasdair Kergon <agk@redhat.com>
Tue, 3 Nov 2009 00:45:35 +0000 (00:45 +0000)
libdm/datastruct/hash.c

index 9f8eff645e545f65c977fe22dc72904f2270d077..3c3d8a0235d85ef7dd336cbd65a2e1a236d79b7f 100644 (file)
@@ -143,9 +143,13 @@ static struct dm_hash_node **_find(struct dm_hash_table *t, const char *key,
        unsigned h = _hash(key, len) & (t->num_slots - 1);
        struct dm_hash_node **c;
 
-       for (c = &t->slots[h]; *c; c = &((*c)->next))
+       for (c = &t->slots[h]; *c; c = &((*c)->next)) {
+               if ((*c)->keylen != len)
+                       continue;
+
                if (!memcmp(key, (*c)->key, len))
                        break;
+       }
 
        return c;
 }
This page took 0.041163 seconds and 5 git commands to generate.