[issue16427] Faster hash implementation

Charles-François Natali report at bugs.python.org
Tue Apr 9 18:51:46 CEST 2013


Charles-François Natali added the comment:

> I'd expect just casting the pointer type before dereferencing:
>
> unsigned char *p;
> ...
> hash = (multiplier * hash) ^ *((Py_uhash_t *)p);
>
> (don't use size_t, use Py_uhash_t)

Is p guaranteed to be size_t aligned?
If not, unaligned access can segfault (e.g. on Sparc IIRC).

> Also it may make DoS attacks easier.

Indeed.
And the increase in collision you demonstrated in your previous
message worries me (both security and performance wise).

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16427>
_______________________________________


More information about the Python-bugs-list mailing list