Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reject unimplemented critical PGP packets as per RFC-4880 #1702

Merged
merged 2 commits into from Jun 15, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 14 additions & 2 deletions rpmio/rpmpgp.c
Expand Up @@ -404,8 +404,10 @@ 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) {
int impl = 0;
i = pgpLen(p, hlen, &plen);
if (i == 0 || plen < 1 || i + plen > hlen)
break;
Expand Down Expand Up @@ -435,6 +437,7 @@ static int pgpPrtSubType(const uint8_t *h, size_t hlen, pgpSigType sigtype,
pgpPrtVal(" ", pgpKeyServerPrefsTbl, p[i]);
break;
case PGPSUBTYPE_SIG_CREATE_TIME:
impl = *p;
if (!(_digp->saved & PGPDIG_SAVED_TIME) &&
(sigtype == PGPSIGTYPE_POSITIVE_CERT || sigtype == PGPSIGTYPE_BINARY || sigtype == PGPSIGTYPE_TEXT || sigtype == PGPSIGTYPE_STANDALONE))
{
Expand All @@ -449,6 +452,7 @@ static int pgpPrtSubType(const uint8_t *h, size_t hlen, pgpSigType sigtype,
break;

case PGPSUBTYPE_ISSUER_KEYID: /* issuer key ID */
impl = *p;
if (!(_digp->saved & PGPDIG_SAVED_ID) &&
(sigtype == PGPSIGTYPE_POSITIVE_CERT || sigtype == PGPSIGTYPE_BINARY || sigtype == PGPSIGTYPE_TEXT || sigtype == PGPSIGTYPE_STANDALONE))
{
Expand Down Expand Up @@ -488,10 +492,18 @@ static int pgpPrtSubType(const uint8_t *h, size_t hlen, pgpSigType sigtype,
break;
}
pgpPrtNL();

if (!impl && (p[0] & PGPSUBTYPE_CRITICAL))
rc = 1;

p += plen;
hlen -= plen;
}
return (hlen != 0); /* non-zero hlen is an error */

if (hlen != 0)
rc = 1;

return rc;
}

pgpDigAlg pgpDigAlgFree(pgpDigAlg alg)
Expand Down