From a2e59180274cc6f928b188da0e7211d01c421883 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Thu, 6 Oct 2011 12:56:13 +0300 Subject: [PATCH] Eliminate redundant NULL-checks in lower level sigchecking functions - sigtd->data and dig checking (where needed) is done at rpmVerifySignature() level, dont bother double-checking - Hash context is dup'ed, which CAN fail, so while we dont need to check the argument for non-null, the dup result needs to be checked for digests. For actual signatures the dup happens elsewhere, we dont need to check the argument for non-null here. --- lib/signature.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/lib/signature.c b/lib/signature.c index 952537729..695b09dd7 100644 --- a/lib/signature.c +++ b/lib/signature.c @@ -398,7 +398,7 @@ verifyMD5Digest(rpmtd sigtd, DIGEST_CTX md5ctx, char **msg) *msg = NULL; DIGEST_CTX ctx = rpmDigestDup(md5ctx); - if (ctx == NULL || sigtd->data == NULL) { + if (ctx == NULL) { rasprintf(msg, "%s %s\n", title, rpmSigString(res)); goto exit; } @@ -438,7 +438,7 @@ verifySHA1Digest(rpmtd sigtd, DIGEST_CTX sha1ctx, char **msg) *msg = NULL; DIGEST_CTX ctx = rpmDigestDup(sha1ctx); - if (ctx == NULL || sigtd->data == NULL) { + if (ctx == NULL) { rasprintf(msg, "%s %s\n", title, rpmSigString(res)); goto exit; } @@ -471,21 +471,15 @@ static rpmRC verifySignature(rpmKeyring keyring, pgpDig dig, DIGEST_CTX hashctx, int isHdr, char **msg) { - pgpDigParams sigp = dig ? &dig->signature : NULL; rpmRC res = RPMRC_FAIL; /* assume failure */ char *sigid = NULL; *msg = NULL; - if (hashctx == NULL) { - goto exit; - } - /* Call verify even if we dont have a key for a basic sanity check */ (void) rpmKeyringLookup(keyring, dig); res = pgpVerifySig(dig, hashctx); -exit: - sigid = pgpIdentItem(sigp); + sigid = pgpIdentItem(&dig->signature); rasprintf(msg, "%s%s: %s\n", isHdr ? _("Header ") : "", sigid, rpmSigString(res)); free(sigid);