mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: always incorporate hash seed at start of hash computation
Otherwise we can get predictable collisions. R=golang-dev, dave, patrick, rsc CC=golang-dev https://golang.org/cl/7051043
This commit is contained in:
parent
c09649890f
commit
63bee953a2
3 changed files with 13 additions and 14 deletions
|
|
@ -19,13 +19,13 @@ runtime·memhash(uintptr *h, uintptr s, void *a)
|
|||
uintptr hash;
|
||||
|
||||
b = a;
|
||||
hash = M0;
|
||||
hash = M0 ^ *h;
|
||||
while(s > 0) {
|
||||
hash = (hash ^ *b) * M1;
|
||||
b++;
|
||||
s--;
|
||||
}
|
||||
*h = (*h ^ hash) * M1;
|
||||
*h = hash;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -355,7 +355,7 @@ void
|
|||
runtime·interhash(uintptr *h, uintptr s, void *a)
|
||||
{
|
||||
USED(s);
|
||||
*h = (*h ^ runtime·ifacehash(*(Iface*)a)) * M1;
|
||||
*h = runtime·ifacehash(*(Iface*)a, *h ^ M0) * M1;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -389,7 +389,7 @@ void
|
|||
runtime·nilinterhash(uintptr *h, uintptr s, void *a)
|
||||
{
|
||||
USED(s);
|
||||
*h = (*h ^ runtime·efacehash(*(Eface*)a)) * M1;
|
||||
*h = runtime·efacehash(*(Eface*)a, *h ^ M0) * M1;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue