1
0
mirror of https://github.com/golang/go synced 2024-11-22 00:04:41 -07:00

crypto/openpgp: fixed dangerous use of for loop variable

In function readSignedMessage a pointer to for loop variable 'key' was incorrectly being assigned
to md.SignedBy. Changed so that md.SignedBy is pointing to the 'more correct' memory position.

R=golang-dev, r, agl
CC=golang-dev
https://golang.org/cl/4631088
This commit is contained in:
Gideon Jan-Wessel Redelinghuys 2011-07-07 10:49:03 +10:00 committed by Rob Pike
parent 7875ecb462
commit 582d6e5848

View File

@ -250,11 +250,12 @@ FindLiteralData:
md.IsSigned = true md.IsSigned = true
md.SignedByKeyId = p.KeyId md.SignedByKeyId = p.KeyId
keys := keyring.KeysById(p.KeyId) keys := keyring.KeysById(p.KeyId)
for _, key := range keys { for i, key := range keys {
if key.SelfSignature.FlagsValid && !key.SelfSignature.FlagSign { if key.SelfSignature.FlagsValid && !key.SelfSignature.FlagSign {
continue continue
} }
md.SignedBy = &key md.SignedBy = &keys[i]
break
} }
case *packet.LiteralData: case *packet.LiteralData:
md.LiteralData = p md.LiteralData = p