Browse Source

go.crypto/bcrypt: fix interger overflow for cost == 31
Fixes golang/go#4803.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7329043

Shenghou Ma 12 năm trước cách đây
mục cha
commit
eccdd1285a
1 tập tin đã thay đổi với 3 bổ sung2 xóa
  1. 3 2
      bcrypt/bcrypt.go

+ 3 - 2
bcrypt/bcrypt.go

@@ -220,8 +220,9 @@ func expensiveBlowfishSetup(key []byte, cost uint32, salt []byte) (*blowfish.Cip
 		return nil, err
 	}
 
-	rounds := 1 << cost
-	for i := 0; i < rounds; i++ {
+	var i, rounds uint64
+	rounds = 1 << cost
+	for i = 0; i < rounds; i++ {
 		blowfish.ExpandKey(ckey, c)
 		blowfish.ExpandKey(csalt, c)
 	}