Ensure correct return code on malformed signature in packages
authorPanu Matilainen <pmatilai@redhat.com>
Fri, 7 Dec 2012 11:54:23 +0000 (13:54 +0200)
committerPanu Matilainen <pmatilai@redhat.com>
Fri, 7 Dec 2012 12:12:44 +0000 (14:12 +0200)
- rpmpkgRead() starts with assumed failure, but there are a number
  of places assigning the return code, and by the time we get
  to the parsePGPSig() calls its likely to be RPMRC_OK, so the
  jumps to exit result in "all is well" return code on a signature
  we couldn't even parse. Oops.
- Set the failure status explicitly to fix this fairly nasty regression
  introduced in commit e8bc3ff5d780f4ee6656c24464402723e5fb04f4, ie
  rpm >= 4.10.
(cherry picked from commit 96a616c6aed4c516789a154af188f005caf23f14)

lib/package.c

index 9ce7130..b6bea09 100644 (file)
@@ -600,8 +600,10 @@ static rpmRC rpmpkgRead(rpmKeyring keyring, rpmVSFlags vsflags,
     switch (sigtag) {
     case RPMSIGTAG_RSA:
     case RPMSIGTAG_DSA:
-       if (parsePGPSig(&sigtd, "package", fn, &sig))
+       if (parsePGPSig(&sigtd, "package", fn, &sig)) {
+           rc = RPMRC_FAIL;
            goto exit;
+       }
        /* fallthrough */
     case RPMSIGTAG_SHA1:
     {  struct rpmtd_s utd;
@@ -619,8 +621,10 @@ static rpmRC rpmpkgRead(rpmKeyring keyring, rpmVSFlags vsflags,
     case RPMSIGTAG_GPG:
     case RPMSIGTAG_PGP5:       /* XXX legacy */
     case RPMSIGTAG_PGP:
-       if (parsePGPSig(&sigtd, "package", fn, &sig))
+       if (parsePGPSig(&sigtd, "package", fn, &sig)) {
+           rc = RPMRC_FAIL;
            goto exit;
+       }
        /* fallthrough */
     case RPMSIGTAG_MD5:
        /* Legacy signatures need the compressed payload in the digest too. */