From 582d6e5848e030564cc131d345e61c29ed936ec5 Mon Sep 17 00:00:00 2001 From: Gideon Jan-Wessel Redelinghuys Date: Thu, 7 Jul 2011 10:49:03 +1000 Subject: [PATCH] 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 --- src/pkg/crypto/openpgp/read.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pkg/crypto/openpgp/read.go b/src/pkg/crypto/openpgp/read.go index 68301475245..d95f613c62b 100644 --- a/src/pkg/crypto/openpgp/read.go +++ b/src/pkg/crypto/openpgp/read.go @@ -250,11 +250,12 @@ FindLiteralData: md.IsSigned = true md.SignedByKeyId = p.KeyId keys := keyring.KeysById(p.KeyId) - for _, key := range keys { + for i, key := range keys { if key.SelfSignature.FlagsValid && !key.SelfSignature.FlagSign { continue } - md.SignedBy = &key + md.SignedBy = &keys[i] + break } case *packet.LiteralData: md.LiteralData = p