Skip to content

Commit

Permalink
Check that alg is NULL, not that pubkey_algo is 0
Browse files Browse the repository at this point in the history
Right now the two are equivalent, but this will no longer be the case if
one can parse a signature without actually loading the
algorithm-specific data.  This will be useful for re-parsing subkey
binding and revocation signatures that have already been validated.
  • Loading branch information
DemiMarie committed Apr 13, 2022
1 parent 714422a commit 6bf8f03
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions rpmio/rpmpgp_internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ static int pgpPrtSig(pgpTag tag, const uint8_t *h, size_t hlen,
pgpPrtHex(" signhash16", v->signhash16, sizeof(v->signhash16));
pgpPrtNL();

if (_digp->pubkey_algo == 0) {
if (_digp->alg == NULL) {
_digp->version = v->version;
_digp->hashlen = v->hashlen;
_digp->sigtype = v->sigtype;
Expand Down Expand Up @@ -498,7 +498,7 @@ static int pgpPrtSig(pgpTag tag, const uint8_t *h, size_t hlen,
if ((p + plen) > hend)
return 1;

if (_digp->pubkey_algo == 0) {
if (_digp->alg == NULL) {
_digp->hashlen = sizeof(*v) + plen;
_digp->hash = memcpy(xmalloc(_digp->hashlen), v, _digp->hashlen);
}
Expand All @@ -525,7 +525,7 @@ static int pgpPrtSig(pgpTag tag, const uint8_t *h, size_t hlen,
pgpPrtHex(" signhash16", p, 2);
pgpPrtNL();

if (_digp->pubkey_algo == 0) {
if (_digp->alg == NULL) {
_digp->version = v->version;
_digp->sigtype = v->sigtype;
_digp->pubkey_algo = v->pubkey_algo;
Expand Down Expand Up @@ -617,8 +617,8 @@ static int pgpPrtKey(pgpTag tag, const uint8_t *h, size_t hlen,
pgpPrtTime(" ", v->time, sizeof(v->time));
pgpPrtNL();

/* If _digp->hash is not NULL then signature is already loaded */
if (_digp->hash == NULL) {
/* If _digp->alg is not NULL then key/signature is already loaded */
if (_digp->alg == NULL) {
_digp->version = v->version;
if (!(_digp->saved & PGPDIG_SAVED_TIME))
_digp->time = pgpGrab(v->time, sizeof(v->time));
Expand Down

0 comments on commit 6bf8f03

Please sign in to comment.