Skip to content

Commit

Permalink
Only set MPIs for signature types we can handle
Browse files Browse the repository at this point in the history
TEXT signatures as those require canonicalized line endings which we
can't handle, and have no need for. Use a switch for the condition
in preparation for oncoming changes, an if only scales so far with
multiple choices.
  • Loading branch information
pmatilai committed Oct 13, 2021
1 parent 5e97c0a commit 55d5811
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions rpmio/rpmpgp.c
Original file line number Diff line number Diff line change
Expand Up @@ -549,17 +549,24 @@ static int pgpPrtSigParams(pgpTag tag, uint8_t pubkey_algo, uint8_t sigtype,
{
int rc = 1; /* assume failure */
const uint8_t * pend = h + hlen;
int i;
int i, impl;
pgpDigAlg sigalg = pgpSignatureNew(pubkey_algo);

switch (sigtype) {
case PGPSIGTYPE_BINARY:
impl = 1;
break;
default:
impl = 0;
break;
}

for (i = 0; i < sigalg->mpis && pend - p >= 2; i++) {
int mpil = pgpMpiLen(p);
if (pend - p < mpil)
break;
if (sigtype == PGPSIGTYPE_BINARY || sigtype == PGPSIGTYPE_TEXT) {
if (sigalg->setmpi(sigalg, i, p))
if (impl && sigalg->setmpi(sigalg, i, p))
break;
}
p += mpil;
}

Expand Down

0 comments on commit 55d5811

Please sign in to comment.