[email protected] wrote:
> Author: bojan
> Date: Sat Jan 28 15:54:22 2012
> New Revision: 1237078
> 
> URL: http://svn.apache.org/viewvc?rev=1237078&view=rev
> Log:
> Further improve hash randomisation:
> Fix naming of a static function.
> Randomise final hash produced by any hash function, using default hash
> function and seed.
> 
> Modified:
>     apr/apr/trunk/tables/apr_hash.c
> 
> Modified: apr/apr/trunk/tables/apr_hash.c
> URL: 
> http://svn.apache.org/viewvc/apr/apr/trunk/tables/apr_hash.c?rev=1237078&r1=1237077&r2=1237078&view=diff
> ==============================================================================
> --- apr/apr/trunk/tables/apr_hash.c (original)
> +++ apr/apr/trunk/tables/apr_hash.c Sat Jan 28 15:54:22 2012

> @@ -290,11 +289,10 @@ static apr_hash_entry_t **find_entry(apr
>  {
>      apr_hash_entry_t **hep, *he;
>      unsigned int hash;
> +    apr_ssize_t hlen = sizeof(hash);
>  
> -    if (ht->hash_func)
> -        hash = ht->hash_func(key, &klen);
> -    else
> -        hash = apr_hashfunc_default_internal(key, &klen, ht->seed);
> +    hash = ht->hash_func(key, &klen);
> +    hash = hashfunc_default((char *)&hash, &hlen, ht->seed);

Don't we have the same issue here as with the XOR version of the patch?
If two different keys (key1, key2) result in the same hash value (so 
ht->hash_func(key1, &klen1) == ht->hash_func(key2,
&klen2);) doesn't hashfunc_default result in the same hash value for both keys 
since the input value to hash
is the same?

>  
>      /* scan linked list */
>      for (hep = &ht->array[hash & ht->max], he = *hep;

Regards

Rüdiger

Reply via email to