summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPanu Matilainen <Panu Matilainen pmatilai@redhat.com>2011-07-13 15:46:21 +0300
committerPanu Matilainen <Panu Matilainen pmatilai@redhat.com>2011-07-15 12:26:42 +0300
commitfd10798215f2e0bb6dd5d66ebb0df76168c5bb39 (patch)
tree0a51fd14ba84d6e832216ee8a90ae4e9d60c30e0
parent4e6dc92f90cd57af0d64f9bd49e6a8cb990a3895 (diff)
downloadrpm-fd10798215f2e0bb6dd5d66ebb0df76168c5bb39.tar.gz
Oops, rpmPubkeyDig() should return NULL if pgpPrtPkts() fails
(cherry picked from commit 612579c6f656f6f8268ed6a05dcdb151477ddaf0)
-rw-r--r--rpmio/rpmkeyring.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/rpmio/rpmkeyring.c b/rpmio/rpmkeyring.c
index 2453289c0..784bc3a48 100644
--- a/rpmio/rpmkeyring.c
+++ b/rpmio/rpmkeyring.c
@@ -173,18 +173,24 @@ pgpDig rpmPubkeyDig(rpmPubkey key)
pgpDig dig = NULL;
static unsigned char zeros[] =
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+ int rc;
if (key == NULL)
return NULL;
dig = pgpNewDig();
- if (pgpPrtPkts(key->pkt, key->pktlen, dig, 0) == 0) {
+ rc = pgpPrtPkts(key->pkt, key->pktlen, dig, 0);
+ if (rc == 0) {
pgpDigParams pubp = &dig->pubkey;
if (!memcmp(pubp->signid, zeros, sizeof(pubp->signid)) ||
!memcmp(pubp->time, zeros, sizeof(pubp->time)) ||
pubp->userid == NULL) {
- dig = pgpFreeDig(dig);
+ rc = -1;
}
}
+
+ if (rc)
+ dig = pgpFreeDig(dig);
+
return dig;
}
@@ -212,9 +218,9 @@ rpmRC rpmKeyringLookup(rpmKeyring keyring, pgpDig sig)
if ((key = rpmKeyringFindKeyid(keyring, &needle))) {
/* Retrieve parameters from pubkey packet(s) */
- (void) pgpPrtPkts(key->pkt, key->pktlen, sig, 0);
+ int pktrc = pgpPrtPkts(key->pkt, key->pktlen, sig, 0);
/* Do the parameters match the signature? */
- if (sigp->pubkey_algo == pubp->pubkey_algo &&
+ if (pktrc == 0 && sigp->pubkey_algo == pubp->pubkey_algo &&
memcmp(sigp->signid, pubp->signid, sizeof(sigp->signid)) == 0) {
res = RPMRC_OK;
}