1
0
mirror of https://github.com/getsops/sops.git synced 2026-02-05 12:45:21 +01:00

pgp/keysource: Check size of key fingerprint

Make sure the key fingerprint is longer than 16 characters before
slicing it.

Closes #463
This commit is contained in:
Benoît Knecht
2019-05-22 14:32:32 +02:00
parent 611dc62a64
commit 1de402b5ad

View File

@@ -58,6 +58,10 @@ func gpgBinary() string {
}
func (key *MasterKey) encryptWithGPGBinary(dataKey []byte) error {
fingerprint := key.Fingerprint
if offset := len(fingerprint) - 16; offset > 0 {
fingerprint = fingerprint[offset:]
}
args := []string{
"--no-default-recipient",
"--yes",
@@ -66,7 +70,7 @@ func (key *MasterKey) encryptWithGPGBinary(dataKey []byte) error {
"-r",
key.Fingerprint,
"--trusted-key",
key.Fingerprint[len(key.Fingerprint)-16:],
fingerprint,
"--no-encrypt-to",
}
cmd := exec.Command(gpgBinary(), args...)