diff --git a/lib/rpmchecksig.c b/lib/rpmchecksig.c index ab78572..beca0e7 100644 --- a/lib/rpmchecksig.c +++ b/lib/rpmchecksig.c @@ -187,11 +187,11 @@ rpmRC rpmpkgRead(struct rpmvs_s *vs, FD_t fd, /* Finalize header range */ rpmvsFiniRange(vs, RPMSIG_HEADER); - /* Unless disabled, read the payload, generating digest(s) on the fly. */ - if (!(rpmvsFlags(vs) & RPMVSF_NEEDPAYLOAD)) { - /* Fish interesting tags from the main header. This is a bit hacky... */ - rpmvsAppendTag(vs, blob, RPMTAG_PAYLOADDIGEST); + /* Fish interesting tags from the main header. This is a bit hacky... */ + rpmvsAppendTag(vs, blob, RPMTAG_PAYLOADDIGEST); + /* If needed and not explicitly disabled, read the payload as well. */ + if (rpmvsRange(vs) & RPMSIG_PAYLOAD) { /* Initialize digests ranging over the payload only */ rpmvsInitRange(vs, RPMSIG_PAYLOAD); diff --git a/lib/rpmvs.c b/lib/rpmvs.c index 622e480..0d475af 100644 --- a/lib/rpmvs.c +++ b/lib/rpmvs.c @@ -396,6 +396,18 @@ void rpmvsFiniRange(struct rpmvs_s *sis, int range) } } +int rpmvsRange(struct rpmvs_s *vs) +{ + int range = 0; + for (int i = 0; i < vs->nsigs; i++) { + if (rpmsinfoDisabled(&vs->sigs[i], vs->vsflags)) + continue; + range |= vs->sigs[i].range; + } + + return range; +} + static int sinfoCmp(const void *a, const void *b) { const struct rpmsinfo_s *sa = a; diff --git a/lib/rpmvs.h b/lib/rpmvs.h index 49d524a..7876fe5 100644 --- a/lib/rpmvs.h +++ b/lib/rpmvs.h @@ -66,6 +66,8 @@ void rpmvsInitRange(struct rpmvs_s *sis, int range); void rpmvsFiniRange(struct rpmvs_s *sis, int range); +int rpmvsRange(struct rpmvs_s *vs); + int rpmvsVerify(struct rpmvs_s *sis, int type, rpmsinfoCb cb, void *cbdata);