pgpPubkeyFingerprint() can fail, propagate errors part II
authorPanu Matilainen <pmatilai@redhat.com>
Tue, 25 Oct 2011 11:03:43 +0000 (14:03 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Tue, 25 Oct 2011 11:03:43 +0000 (14:03 +0300)
- rpmPubkeyNew() needs to return NULL if we fail to grab the
  keyid, make it so...

rpmio/rpmkeyring.c

index 784bc3a..208e290 100644 (file)
@@ -124,16 +124,20 @@ exit:
 rpmPubkey rpmPubkeyNew(const uint8_t *pkt, size_t pktlen)
 {
     rpmPubkey key = NULL;
+    pgpKeyID_t keyid;
     
     if (pkt == NULL || pktlen == 0)
        goto exit;
 
+    if (pgpPubkeyFingerprint(pkt, pktlen, keyid))
+       goto exit;
+
     key = xcalloc(1, sizeof(*key));
-    pgpPubkeyFingerprint(pkt, pktlen, key->keyid);
     key->pkt = xmalloc(pktlen);
     key->pktlen = pktlen;
     key->nrefs = 0;
     memcpy(key->pkt, pkt, pktlen);
+    memcpy(key->keyid, keyid, sizeof(keyid));
 
 exit:
     return rpmPubkeyLink(key);