summaryrefslogtreecommitdiff
path: root/backport-Make-pgpPubkeyFingerprint-do-something-meaningful-ag.patch
diff options
context:
space:
mode:
Diffstat (limited to 'backport-Make-pgpPubkeyFingerprint-do-something-meaningful-ag.patch')
-rw-r--r--backport-Make-pgpPubkeyFingerprint-do-something-meaningful-ag.patch64
1 files changed, 64 insertions, 0 deletions
diff --git a/backport-Make-pgpPubkeyFingerprint-do-something-meaningful-ag.patch b/backport-Make-pgpPubkeyFingerprint-do-something-meaningful-ag.patch
new file mode 100644
index 0000000..8cac6e0
--- /dev/null
+++ b/backport-Make-pgpPubkeyFingerprint-do-something-meaningful-ag.patch
@@ -0,0 +1,64 @@
+From dc9e8169790eba18130fb96c13f56ecba6c9b346 Mon Sep 17 00:00:00 2001
+From: Panu Matilainen <pmatilai@redhat.com>
+Date: Tue, 6 Sep 2022 09:28:10 +0300
+Subject: [PATCH] Make pgpPubkeyFingerprint() do something meaningful again
+
+Commit 4bbeec134aab33e24f960be28a7b2198359c1f67 "fixed" an old
+terminology confusion about keyid vs fingerprint, but in the process
+broke pgpPubkeyFingerprint() for any external callers, as it now only
+feeds on decoded packets whereas before it did the decoding by itself.
+Add the decoding step back to the public function to make it usable outside
+rpmpgp_internal.c again, retrieving a fingerprint seems like an useful
+(public) API to have.
+
+This is kind of a regression fix in that prior to commit
+4bbeec134aab33e24f960be28a7b2198359c1f67 pgpPubkeyFingerprint() returned
+meaningful data to the outside caller and afterwards it didn't, however
+that commit broke the API anyhow so it's kinda complicated.
+Maybe we should just call it a bugfix and be done with it.
+
+Related to #1549
+---
+ rpmio/rpmpgp.c | 15 +++++++++++++--
+ 1 file changed, 13 insertions(+), 2 deletions(-)
+
+diff --git a/rpmio/rpmpgp.c b/rpmio/rpmpgp.c
+index d4dd4b89d..8d0d76869 100644
+--- a/rpmio/rpmpgp.c
++++ b/rpmio/rpmpgp.c
+@@ -650,7 +650,7 @@ static int pgpPrtUserID(pgpTag tag, const uint8_t *h, size_t hlen,
+ return 0;
+ }
+
+-int pgpPubkeyFingerprint(const uint8_t *h, size_t hlen,
++static int getPubkeyFingerprint(const uint8_t *h, size_t hlen,
+ uint8_t **fp, size_t *fplen)
+ {
+ int rc = -1; /* assume failure */
+@@ -717,11 +717,22 @@ int pgpPubkeyFingerprint(const uint8_t *h, size_t hlen,
+ return rc;
+ }
+
++int pgpPubkeyFingerprint(const uint8_t * pkt, size_t pktlen,
++ uint8_t **fp, size_t *fplen)
++{
++ struct pgpPkt p;
++
++ if (decodePkt(pkt, pktlen, &p))
++ return -1;
++
++ return getPubkeyFingerprint(p.body, p.blen, fp, fplen);
++}
++
+ static int getKeyID(const uint8_t *h, size_t hlen, pgpKeyID_t keyid)
+ {
+ uint8_t *fp = NULL;
+ size_t fplen = 0;
+- int rc = pgpPubkeyFingerprint(h, hlen, &fp, &fplen);
++ int rc = getPubkeyFingerprint(h, hlen, &fp, &fplen);
+ if (fp && fplen > 8) {
+ memcpy(keyid, (fp + (fplen-8)), 8);
+ free(fp);
+--
+2.33.0
+