}
static unsigned char *
-unarmor(char *pubkey, int *pktlp)
+unarmor(char *pubkey, int *pktlp, char *startstr, char *endstr)
{
char *p;
int l, eof;
unsigned int v;
*pktlp = 0;
- while (strncmp(pubkey, "-----BEGIN PGP PUBLIC KEY BLOCK-----", 36) != 0)
+ l = strlen(startstr);
+ while (strncmp(pubkey, startstr, l) != 0)
{
pubkey = strchr(pubkey, '\n');
if (!pubkey)
}
while (*pubkey == ' ' || *pubkey == '\t' || *pubkey == '\n' || *pubkey == '\r')
pubkey++;
- if (strncmp(pubkey, "-----END PGP PUBLIC KEY BLOCK-----", 34) != 0)
+ if (strncmp(pubkey, endstr, strlen(endstr)) != 0)
{
solv_free(buf);
return 0;
unsigned char *pkts;
int pktsl;
- pkts = unarmor(pubkey, &pktsl);
+ pkts = unarmor(pubkey, &pktsl, "-----BEGIN PGP PUBLIC KEY BLOCK-----", "-----END PGP PUBLIC KEY BLOCK-----");
if (!pkts)
{
pool_error(s->repo->pool, 0, "unarmor failure");
return 0;
bits = mpi[0] << 8 | mpi[1];
l = 2 + (bits + 7) / 8;
- if (bits > maxbits || mpil < l)
+ if (bits > maxbits || mpil < l || (bits && !mpi[2]))
{
*mpilp = 0;
return 0;