]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: hash - Add assert to make sure hash table doesn't grow beyond UINT_MAX nodes
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 20 May 2020 10:42:22 +0000 (13:42 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Fri, 15 Jan 2021 17:26:51 +0000 (17:26 +0000)
hash_table_count() returns unsigned int, so the node count can't be larger.
It's internally also tracked as unsigned int currently. It should be large
enough for all practical use cases.

src/lib/hash.c

index 76d51baaaabda335596e8199da603f95e48758c0..16f3c967238a148eadecf70f96a71d89b21ea63a 100644 (file)
@@ -219,6 +219,7 @@ hash_table_insert_node(struct hash_table *table, void *key, void *value,
        unsigned int hash;
        bool check_existing = TRUE;
 
+       i_assert(table->nodes_count < UINT_MAX);
        i_assert(key != NULL);
 
        if(opcode == HASH_TABLE_OP_RESIZE)