Take advantage of parsePGPSig() in pgpsigFormat() too
authorPanu Matilainen <pmatilai@redhat.com>
Mon, 7 Nov 2011 09:19:25 +0000 (11:19 +0200)
committerPanu Matilainen <pmatilai@redhat.com>
Mon, 7 Nov 2011 09:21:31 +0000 (11:21 +0200)
- Doesn't make for less lines in this case but unifying the accesses
  is good anyway.

lib/formats.c
lib/package.c

index fb20355..5b9f26a 100644 (file)
@@ -16,6 +16,7 @@
 #include "rpmio/digest.h"
 #include "lib/manifest.h"
 #include "lib/misc.h"
+#include "lib/signature.h"
 
 #include "debug.h"
 
@@ -422,10 +423,10 @@ static char * pgpsigFormat(rpmtd td)
     if (rpmtdType(td) != RPM_BIN_TYPE) {
        val = xstrdup(_("(not a blob)"));
     } else {
-       pgpDig dig = pgpNewDig();
-       pgpDigParams sigp = &dig->signature;
+       pgpDig dig = NULL;
+       pgpDigParams sigp = parsePGPSig(td, NULL, NULL, &dig);
 
-       if (pgpPrtPkts(td->data, td->count, dig, 0) || sigp->version == 0) {
+       if (sigp == NULL) {
            val = xstrdup(_("(not an OpenPGP signature)"));
        } else {
            char dbuf[BUFSIZ];
@@ -446,8 +447,8 @@ static char * pgpsigFormat(rpmtd td)
                        dbuf, keyid);
 
            free(keyid);
+           pgpFreeDig(dig);
        }
-       pgpFreeDig(dig);
     }
 
     return val;
index 4dd7f28..37e34ad 100644 (file)
@@ -147,10 +147,10 @@ pgpDigParams parsePGPSig(rpmtd sigtd, const char *type, const char *fn,
     if ((pgpPrtPkts(sigtd->data, sigtd->count, dig, debug) == 0)) {
        *digp = dig;
     } else {
-       if (fn) {
+       if (type && fn) {
            rpmlog(RPMLOG_ERR,
                   _("skipping %s %s with unverifiable signature\n"), type, fn);
-       } else {
+       } else if (type) {
            rpmlog(RPMLOG_ERR,
                   _("skipping %s with unverifiable signature\n"), type);
        }