diff options
author | Werner Koch <wk@gnupg.org> | 2018-12-04 15:43:19 +0100 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2018-12-04 15:43:19 +0100 |
commit | c6e2ee020784de63edfa83c76095e086eae49eef (patch) | |
tree | 54c84e99311f06dc18cf38dfea1794a2e984b87e /g10/revoke.c | |
parent | wks: Allow reading of --install-key arguments from stdin. (diff) | |
download | gnupg2-c6e2ee020784de63edfa83c76095e086eae49eef.tar.xz gnupg2-c6e2ee020784de63edfa83c76095e086eae49eef.zip |
gpg: Prepare revocation keys for use with v5 keys.
* g10/packet.h (struct revocation_key): Add field 'fprlen'.
* g10/parse-packet.c (parse_revkeys): Set fprlen and allow for v5
keys. Also fix reading of unitialized data at place where
MAX_FINGERPRINT_LEN is used.
* g10/revoke.c (gen_desig_revoke): Allow for v5 keys and use fprlen.
Do an explicit compare to avoid reading unitialized data.
* g10/sig-check.c (check_revocation_keys): Use the fprlen.
* g10/getkey.c (merge_selfsigs_main): Do an explicit copy to avoid
reading unitialized data.
* g10/import.c (revocation_present): Use fprlen.
* g10/keyedit.c (show_key_with_all_names): Use fprlen.
(menu_addrevoker): Use fprlen. Allow for v5 keys.
* g10/keygen.c (keygen_add_revkey): Use fprlen.
(parse_revocation_key): Allow for v5 keys.
* g10/keyid.c (keyid_from_fingerprint): Allow for v5 keys. Print a
better error message in case of bogus fingerprints.
* g10/keylist.c (print_revokers): Use fprlen.
--
The reading of uninitialized data is harmless but we better fix it to
make valgrind happy. More serious was that we always passed
MAX_FINGERPRINT_LEN but we will need to support 20 and 32 octet
fingerprints and MAX_FINGERPRINT_LEN would be too large for a v4.
Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'g10/revoke.c')
-rw-r--r-- | g10/revoke.c | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/g10/revoke.c b/g10/revoke.c index b778684b0..e8ce3544c 100644 --- a/g10/revoke.c +++ b/g10/revoke.c @@ -277,12 +277,12 @@ gen_desig_revoke (ctrl_t ctrl, const char *uname, strlist_t locusr) fingerprint_from_pk (list->pk, fpr, &fprlen); - /* Don't get involved with keys that don't have 160 - bit fingerprints */ - if(fprlen!=20) + /* Don't get involved with keys that don't have a v4 + * or v5 fingerprint */ + if (fprlen != 20 && fprlen != 32) continue; - if(memcmp(fpr,pk->revkey[i].fpr,20)==0) + if (!memcmp(fpr,pk->revkey[i].fpr, fprlen)) break; } @@ -295,7 +295,7 @@ gen_desig_revoke (ctrl_t ctrl, const char *uname, strlist_t locusr) { pk2 = xmalloc_clear (sizeof *pk2); rc = get_pubkey_byfprint (ctrl, pk2, NULL, - pk->revkey[i].fpr, MAX_FINGERPRINT_LEN); + pk->revkey[i].fpr, pk->revkey[i].fprlen); } /* We have the revocation key. */ @@ -388,15 +388,18 @@ gen_desig_revoke (ctrl_t ctrl, const char *uname, strlist_t locusr) for(j=0;j<signode->pkt->pkt.signature->numrevkeys;j++) { - if(pk->revkey[i].class== - signode->pkt->pkt.signature->revkey[j].class && - pk->revkey[i].algid== - signode->pkt->pkt.signature->revkey[j].algid && - memcmp(pk->revkey[i].fpr, - signode->pkt->pkt.signature->revkey[j].fpr, - MAX_FINGERPRINT_LEN)==0) + if (pk->revkey[i].class + == signode->pkt->pkt.signature->revkey[j].class + && pk->revkey[i].algid + == signode->pkt->pkt.signature->revkey[j].algid + && pk->revkey[i].fprlen + == signode->pkt->pkt.signature->revkey[j].fprlen + && !memcmp + (pk->revkey[i].fpr, + signode->pkt->pkt.signature->revkey[j].fpr, + pk->revkey[i].fprlen)) { - revkey=signode->pkt->pkt.signature; + revkey = signode->pkt->pkt.signature; break; } } |