From a9e0935af8815099b51c1b0933aacf1aa4ce8687 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Mon, 17 Aug 2020 01:10:02 -0700 Subject: [PATCH] Util: Ensure key sizes match before comparing --- src/util/table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/table.c b/src/util/table.c index 658611f57..5557feaef 100644 --- a/src/util/table.c +++ b/src/util/table.c @@ -14,7 +14,7 @@ #define TABLE_COMPARATOR(LIST, INDEX) LIST->list[(INDEX)].key == key #define HASH_TABLE_STRNCMP_COMPARATOR(LIST, INDEX) LIST->list[(INDEX)].key == hash && strncmp(LIST->list[(INDEX)].stringKey, key, LIST->list[(INDEX)].keylen) == 0 -#define HASH_TABLE_MEMCMP_COMPARATOR(LIST, INDEX) LIST->list[(INDEX)].key == hash && memcmp(LIST->list[(INDEX)].stringKey, key, LIST->list[(INDEX)].keylen) == 0 +#define HASH_TABLE_MEMCMP_COMPARATOR(LIST, INDEX) LIST->list[(INDEX)].key == hash && LIST->list[(INDEX)].keylen == keylen && memcmp(LIST->list[(INDEX)].stringKey, key, LIST->list[(INDEX)].keylen) == 0 #define TABLE_LOOKUP_START(COMPARATOR, LIST) \ size_t i; \