teknoraver / rpms / rpm

Forked from rpms/rpm 4 months ago
Clone

Blame rpm-4.9.90-keyid-size.patch

Panu Matilainen e56f27
commit c5a140133505dbe3cf59c97bbf40c2f5526e5f5b
Panu Matilainen e56f27
Author: Panu Matilainen <pmatilai@redhat.com>
Panu Matilainen e56f27
Date:   Thu Mar 22 12:24:55 2012 +0200
Panu Matilainen e56f27
Panu Matilainen e56f27
    Oops, "magic eight" is necessary here afterall
Panu Matilainen e56f27
    
Panu Matilainen e56f27
    - Fix regression from commit 807b402d95702f3f91e9e2bfbd2b5ca8c9964ed9,
Panu Matilainen e56f27
      the array gets passed as a pointer (how else would it work at all),
Panu Matilainen e56f27
      so despite having seemingly correct type, sizeof(keyid) depends
Panu Matilainen e56f27
      on the pointer size. This happens to be 8 on x86_64 and friends
Panu Matilainen e56f27
      but breaks on eg i386.
Panu Matilainen e56f27
    - Also return the explicit size from pgpExtractPubkeyFingerprint(),
Panu Matilainen e56f27
      this has been "broken" for much longer but then all callers should
Panu Matilainen e56f27
      really care about is -1 for error.
Panu Matilainen e56f27
Panu Matilainen e56f27
diff --git a/rpmio/rpmpgp.c b/rpmio/rpmpgp.c
Panu Matilainen e56f27
index 4aac23d..e70cf70 100644
Panu Matilainen e56f27
--- a/rpmio/rpmpgp.c
Panu Matilainen e56f27
+++ b/rpmio/rpmpgp.c
Panu Matilainen e56f27
@@ -757,7 +757,7 @@ static int getFingerprint(const uint8_t *h, size_t hlen, pgpKeyID_t keyid)
Panu Matilainen e56f27
 	    (void) rpmDigestFinal(ctx, (void **)&d, &dlen, 0);
Panu Matilainen e56f27
 
Panu Matilainen e56f27
 	    if (d) {
Panu Matilainen e56f27
-		memcpy(keyid, (d + (dlen-sizeof(keyid))), sizeof(keyid));
Panu Matilainen e56f27
+		memcpy(keyid, (d + (dlen-8)), 8);
Panu Matilainen e56f27
 		free(d);
Panu Matilainen e56f27
 		rc = 0;
Panu Matilainen e56f27
 	    }
Panu Matilainen e56f27
@@ -787,7 +787,7 @@ int pgpExtractPubkeyFingerprint(const char * b64pkt, pgpKeyID_t keyid)
Panu Matilainen e56f27
     if (rpmBase64Decode(b64pkt, (void **)&pkt, &pktlen) == 0) {
Panu Matilainen e56f27
 	if (pgpPubkeyFingerprint(pkt, pktlen, keyid) == 0) {
Panu Matilainen e56f27
 	    /* if there ever was a bizarre return code for success... */
Panu Matilainen e56f27
-	    rc = sizeof(keyid);
Panu Matilainen e56f27
+	    rc = 8;
Panu Matilainen e56f27
 	}
Panu Matilainen e56f27
 	free(pkt);
Panu Matilainen e56f27
     }