Skip to content

Commit aebe91d

Browse files
committed
Fix constantTimeCompare.
1 parent df71f66 commit aebe91d

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

group/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ var hashSemaphore = make(chan struct{}, runtime.GOMAXPROCS(-1))
3535
func constantTimeCompare(a, b string) bool {
3636
as := []byte(a)
3737
bs := make([]byte, len(as))
38-
copy(bs, a)
38+
copy(bs, b)
3939
equal := subtle.ConstantTimeCompare(as, bs) == 1
4040
return len(a) == len(b) && equal
4141
}

group/client_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ func TestGood(t *testing.T) {
5858

5959
func TestBad(t *testing.T) {
6060
if match, err := pw2.Match("bad"); err != nil || match {
61-
t.Errorf("pw2 matches")
61+
t.Errorf("pw2 matches bad")
62+
}
63+
if match, err := pw2.Match("bad1"); err != nil || match {
64+
t.Errorf("pw2 matches bad1")
6265
}
6366
if match, err := pw3.Match("bad"); err != nil || match {
6467
t.Errorf("pw3 matches")

0 commit comments

Comments
 (0)