summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2021-06-15 13:56:44 +0300
committerPanu Matilainen <pmatilai@redhat.com>2021-06-15 16:36:13 +0300
commit66f40d2e347b7f2ff94413c4b4107e39dd91a9dc (patch)
tree225e94cdcaa01aa98696e6381bd1982ecf6a8b5e
parent201e38372d8cd6259790c3364104cf25cdc37492 (diff)
downloadrpm-66f40d2e347b7f2ff94413c4b4107e39dd91a9dc.tar.gz
Refactor error tracking to helper variable in PGP subtype parsing
No functional changes here, but makes easier to flag different errors in the next commits.
-rw-r--r--rpmio/rpmpgp.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/rpmio/rpmpgp.c b/rpmio/rpmpgp.c
index 4a6e54fea..e0a8a1054 100644
--- a/rpmio/rpmpgp.c
+++ b/rpmio/rpmpgp.c
@@ -404,8 +404,9 @@ static int pgpPrtSubType(const uint8_t *h, size_t hlen, pgpSigType sigtype,
{
const uint8_t *p = h;
size_t plen = 0, i;
+ int rc = 0;
- while (hlen > 0) {
+ while (hlen > 0 && rc == 0) {
i = pgpLen(p, hlen, &plen);
if (i == 0 || plen < 1 || i + plen > hlen)
break;
@@ -491,7 +492,11 @@ static int pgpPrtSubType(const uint8_t *h, size_t hlen, pgpSigType sigtype,
p += plen;
hlen -= plen;
}
- return (hlen != 0); /* non-zero hlen is an error */
+
+ if (hlen != 0)
+ rc = 1;
+
+ return rc;
}
pgpDigAlg pgpDigAlgFree(pgpDigAlg alg)