From d7041cc8a0455346446f435bf1b305c56f3e7241 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Thu, 6 Oct 2011 13:06:28 +0300 Subject: [PATCH] Only bother allocating a pgpDig when needed - Now that rpmVerifySignature() doesn't require a non-null dig for digests, don't bother allocating one unless necessary. - pgpNewDig() cannot fail so dont bother checking. --- lib/package.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/lib/package.c b/lib/package.c index fc1e20e..3fc015c 100644 --- a/lib/package.c +++ b/lib/package.c @@ -277,9 +277,6 @@ static rpmRC headerSigVerify(rpmKeyring keyring, rpmVSFlags vsflags, goto exit; } - /* This is dumb, pgpDig is only relevant for signatures, not digests */ - dig = pgpNewDig(); - sigtd.tag = info.tag; sigtd.type = info.type; sigtd.count = info.count; @@ -289,6 +286,7 @@ static rpmRC headerSigVerify(rpmKeyring keyring, rpmVSFlags vsflags, switch (info.tag) { case RPMTAG_RSAHEADER: case RPMTAG_DSAHEADER: + dig = pgpNewDig(); if ((rc = parsePGP(&sigtd, "header", dig)) != RPMRC_OK) { goto exit; } @@ -630,12 +628,6 @@ static rpmRC rpmpkgRead(rpmKeyring keyring, rpmVSFlags vsflags, goto exit; } - dig = pgpNewDig(); - if (dig == NULL) { - rc = RPMRC_FAIL; - goto exit; - } - /* Retrieve the tag parameters from the signature header. */ if (!headerGet(sigh, sigtag, &sigtd, hgeflags)) { rc = RPMRC_FAIL; @@ -645,6 +637,7 @@ static rpmRC rpmpkgRead(rpmKeyring keyring, rpmVSFlags vsflags, switch (sigtag) { case RPMSIGTAG_RSA: case RPMSIGTAG_DSA: + dig = pgpNewDig(); if ((rc = parsePGP(&sigtd, "package", dig)) != RPMRC_OK) { goto exit; } @@ -664,6 +657,7 @@ static rpmRC rpmpkgRead(rpmKeyring keyring, rpmVSFlags vsflags, case RPMSIGTAG_GPG: case RPMSIGTAG_PGP5: /* XXX legacy */ case RPMSIGTAG_PGP: + dig = pgpNewDig(); if ((rc = parsePGP(&sigtd, "package", dig)) != RPMRC_OK) { goto exit; } -- 2.7.4