Skip to content

Commit

Permalink
Fix out of bounds copy on malformed PGP packet (#148)
Browse files Browse the repository at this point in the history
Validate the packet is of correct size for the keyid type before
copying. Ditto for similar code in signature creation time.
  • Loading branch information
pmatilai committed Feb 7, 2017
1 parent e843855 commit 657553f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions rpmio/rpmpgp.c
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,8 @@ static int pgpPrtSubType(const uint8_t *h, size_t hlen, pgpSigType sigtype,
if (!(_digp->saved & PGPDIG_SAVED_TIME) &&
(sigtype == PGPSIGTYPE_POSITIVE_CERT || sigtype == PGPSIGTYPE_BINARY || sigtype == PGPSIGTYPE_TEXT || sigtype == PGPSIGTYPE_STANDALONE))
{
if (plen-1 != sizeof(_digp->time))
break;
_digp->saved |= PGPDIG_SAVED_TIME;
memcpy(_digp->time, p+1, sizeof(_digp->time));
}
Expand All @@ -440,6 +442,8 @@ static int pgpPrtSubType(const uint8_t *h, size_t hlen, pgpSigType sigtype,
if (!(_digp->saved & PGPDIG_SAVED_ID) &&
(sigtype == PGPSIGTYPE_POSITIVE_CERT || sigtype == PGPSIGTYPE_BINARY || sigtype == PGPSIGTYPE_TEXT || sigtype == PGPSIGTYPE_STANDALONE))
{
if (plen-1 != sizeof(_digp->signid))
break;
_digp->saved |= PGPDIG_SAVED_ID;
memcpy(_digp->signid, p+1, sizeof(_digp->signid));
}
Expand Down

0 comments on commit 657553f

Please sign in to comment.