浏览代码

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 年之前
父节点
当前提交
eccdd1285a
共有 1 个文件被更改,包括 3 次插入2 次删除
  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)
 	}