diff options
author | Michael Schroeder <mls@suse.de> | 2013-08-23 11:32:47 +0200 |
---|---|---|
committer | Michael Schroeder <mls@suse.de> | 2013-08-23 11:32:47 +0200 |
commit | 41a431ab1d37ed5a41a5475189f5b1a6812c51f2 (patch) | |
tree | 5b2272be7b4aa8b994567bfb817fbe22509a42bb /ext/repo_pubkey.c | |
parent | 538a7f16fd8dc8e98a534d22fb46dbd80e6fd30a (diff) | |
download | libsolv-41a431ab1d37ed5a41a5475189f5b1a6812c51f2.tar.gz libsolv-41a431ab1d37ed5a41a5475189f5b1a6812c51f2.tar.bz2 libsolv-41a431ab1d37ed5a41a5475189f5b1a6812c51f2.zip |
make unarmor() more flexible, make sure pgp mpis are minimal
Diffstat (limited to 'ext/repo_pubkey.c')
-rw-r--r-- | ext/repo_pubkey.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/ext/repo_pubkey.c b/ext/repo_pubkey.c index 7b196cb..077f524 100644 --- a/ext/repo_pubkey.c +++ b/ext/repo_pubkey.c @@ -113,7 +113,7 @@ crc24(unsigned char *p, int len) } static unsigned char * -unarmor(char *pubkey, int *pktlp) +unarmor(char *pubkey, int *pktlp, char *startstr, char *endstr) { char *p; int l, eof; @@ -121,7 +121,8 @@ unarmor(char *pubkey, int *pktlp) 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) @@ -176,7 +177,7 @@ unarmor(char *pubkey, int *pktlp) } 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; @@ -693,7 +694,7 @@ pubkey2solvable(Solvable *s, Repodata *data, char *pubkey) 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"); |