diff --git a/group/client.go b/group/client.go index 9a33d1f..a018e2c 100644 --- a/group/client.go +++ b/group/client.go @@ -35,7 +35,7 @@ var hashSemaphore = make(chan struct{}, runtime.GOMAXPROCS(-1)) func constantTimeCompare(a, b string) bool { as := []byte(a) bs := make([]byte, len(as)) - copy(bs, a) + copy(bs, b) equal := subtle.ConstantTimeCompare(as, bs) == 1 return len(a) == len(b) && equal } diff --git a/group/client_test.go b/group/client_test.go index 623510a..b0f0581 100644 --- a/group/client_test.go +++ b/group/client_test.go @@ -58,7 +58,10 @@ func TestGood(t *testing.T) { func TestBad(t *testing.T) { if match, err := pw2.Match("bad"); err != nil || match { - t.Errorf("pw2 matches") + t.Errorf("pw2 matches bad") + } + if match, err := pw2.Match("bad1"); err != nil || match { + t.Errorf("pw2 matches bad1") } if match, err := pw3.Match("bad"); err != nil || match { t.Errorf("pw3 matches")