diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2011-10-24 12:39:51 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2011-10-24 12:52:26 +0300 |
commit | a2d14f6b6517ee31743a77b07c1346438ba6d2e1 (patch) | |
tree | 5ff749d2d5f6dd7418d73536a7304ea1e50e2e8c | |
parent | 97a452f732a256e033c16b4b87a8674b91429b45 (diff) | |
download | librpm-tizen-a2d14f6b6517ee31743a77b07c1346438ba6d2e1.tar.gz librpm-tizen-a2d14f6b6517ee31743a77b07c1346438ba6d2e1.tar.bz2 librpm-tizen-a2d14f6b6517ee31743a77b07c1346438ba6d2e1.zip |
Eliminate broken pgpLen() from the API
- pgpLen() only works for new format packets, and even for those
its unsafe and cannot be fixed without breaking the API. Start
by taking it behind the barn for further, err, operations. Rpm has
no users outside rpmpgp.c now and anybody else using it will be
better off not doing so.
-rw-r--r-- | rpmio/rpmpgp.c | 21 | ||||
-rw-r--r-- | rpmio/rpmpgp.h | 21 |
2 files changed, 21 insertions, 21 deletions
diff --git a/rpmio/rpmpgp.c b/rpmio/rpmpgp.c index 9f925156f..fd05c2e69 100644 --- a/rpmio/rpmpgp.c +++ b/rpmio/rpmpgp.c @@ -400,6 +400,27 @@ static SECKEYPublicKey *pgpNewPublicKey(KeyType type) } /** \ingroup rpmpgp + * Return length of an OpenPGP packet. + * @param s pointer to packet + * @retval *lenp no. of bytes in packet + * @return no. of bytes in length prefix + */ +static inline +size_t pgpLen(const uint8_t *s, size_t * lenp) +{ + if (*s < 192) { + (*lenp) = *s++; + return 1; + } else if (*s < 255) { + (*lenp) = ((((unsigned)s[0]) - 192) << 8) + s[1] + 192; + return 2; + } else { + (*lenp) = pgpGrab(s+1, (size_t) 4); + return 5; + } +} + +/** \ingroup rpmpgp * Is buffer at beginning of an OpenPGP packet? * @param p buffer * @return 1 if an OpenPGP packet, 0 otherwise diff --git a/rpmio/rpmpgp.h b/rpmio/rpmpgp.h index 6d484f3fb..00f960639 100644 --- a/rpmio/rpmpgp.h +++ b/rpmio/rpmpgp.h @@ -961,27 +961,6 @@ unsigned int pgpGrab(const uint8_t *s, size_t nbytes) } /** \ingroup rpmpgp - * Return length of an OpenPGP packet. - * @param s pointer to packet - * @retval *lenp no. of bytes in packet - * @return no. of bytes in length prefix - */ -static inline -size_t pgpLen(const uint8_t *s, size_t * lenp) -{ - if (*s < 192) { - (*lenp) = *s++; - return 1; - } else if (*s < 255) { - (*lenp) = ((((unsigned)s[0]) - 192) << 8) + s[1] + 192; - return 2; - } else { - (*lenp) = pgpGrab(s+1, (size_t) 4); - return 5; - } -} - -/** \ingroup rpmpgp * Return hex formatted representation of bytes. * @param p bytes * @param plen no. of bytes |