Permit DOS line-endings in PGP armors (RhBug:532992)
authorPanu Matilainen <pmatilai@redhat.com>
Tue, 1 Jun 2010 08:58:42 +0000 (11:58 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Tue, 1 Jun 2010 08:58:42 +0000 (11:58 +0300)
- RFC-4880 doesn't requires unix-style line-endings, we shouldn't either.
  This is probably still oversly strict as RFC-4880 appears to permit
  any whitespace to follow armor headers but ... shrug.

rpmio/rpmpgp.c

index 0863a05..39282bb 100644 (file)
@@ -1471,10 +1471,13 @@ static pgpArmor decodePkts(uint8_t *b, uint8_t **pkt, size_t *pktlen)
            }
            if (rc != PGPARMOR_PUBKEY)  /* XXX ASCII Pubkeys only, please. */
                continue;
-           armortype = t;
 
-           t = te - (sizeof("-----\n")-1);
-           if (!TOKEQ(t, "-----\n"))
+           armortype = pgpValStr(pgpArmorTbl, rc);
+           t += strlen(armortype);
+           if (!TOKEQ(t, "-----"))
+               continue;
+           t += sizeof("-----")-1;
+           if (*t != '\n' && *t != '\r')
                continue;
            *t = '\0';
            pstate++;
@@ -1484,7 +1487,7 @@ static pgpArmor decodePkts(uint8_t *b, uint8_t **pkt, size_t *pktlen)
            rc = pgpValTok(pgpArmorKeyTbl, t, te);
            if (rc >= 0)
                continue;
-           if (*t != '\n') {
+           if (*t != '\n' && *t != '\r') {
                pstate = 0;
                continue;
            }