mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-07-22 16:47:21 +03:00
Handle unaligned keys in hash().
Reported by Christopher Ferris <cferris@google.com>.
This commit is contained in:
parent
9f24c94474
commit
a0aaad1afa
2 changed files with 33 additions and 4 deletions
|
|
@ -59,17 +59,17 @@ hash_variant_string(hash_variant_t variant)
|
|||
}
|
||||
}
|
||||
|
||||
#define KEY_SIZE 256
|
||||
static void
|
||||
hash_variant_verify(hash_variant_t variant)
|
||||
hash_variant_verify_key(hash_variant_t variant, uint8_t *key)
|
||||
{
|
||||
const size_t hashbytes = hash_variant_bits(variant) / 8;
|
||||
uint8_t key[256];
|
||||
VARIABLE_ARRAY(uint8_t, hashes, hashbytes * 256);
|
||||
VARIABLE_ARRAY(uint8_t, final, hashbytes);
|
||||
unsigned i;
|
||||
uint32_t computed, expected;
|
||||
|
||||
memset(key, 0, sizeof(key));
|
||||
memset(key, 0, KEY_SIZE);
|
||||
memset(hashes, 0, sizeof(hashes));
|
||||
memset(final, 0, sizeof(final));
|
||||
|
||||
|
|
@ -139,6 +139,19 @@ hash_variant_verify(hash_variant_t variant)
|
|||
hash_variant_string(variant), expected, computed);
|
||||
}
|
||||
|
||||
static void
|
||||
hash_variant_verify(hash_variant_t variant)
|
||||
{
|
||||
#define MAX_ALIGN 16
|
||||
uint8_t key[KEY_SIZE + (MAX_ALIGN - 1)];
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < MAX_ALIGN; i++)
|
||||
hash_variant_verify_key(variant, &key[i]);
|
||||
#undef MAX_ALIGN
|
||||
}
|
||||
#undef KEY_SIZE
|
||||
|
||||
TEST_BEGIN(test_hash_x86_32)
|
||||
{
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue