summaryrefslogtreecommitdiff
path: root/rpmio
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2008-04-07 13:02:18 +0300
committerPanu Matilainen <pmatilai@redhat.com>2008-04-07 13:02:18 +0300
commita3a1a45c5131fd1dd885cd73bb9f6a7ac1ddbfba (patch)
tree711bafbc09f24954167cb13c68cf3c502b65dbdd /rpmio
parenta70823b99814cbef36ccb1a056f9ef1e97bd7ae2 (diff)
downloadrpm-a3a1a45c5131fd1dd885cd73bb9f6a7ac1ddbfba.tar.gz
rpm-a3a1a45c5131fd1dd885cd73bb9f6a7ac1ddbfba.tar.bz2
rpm-a3a1a45c5131fd1dd885cd73bb9f6a7ac1ddbfba.zip
Remove static print buffer from pgpHexStr, return malloc'ed memory instead
- inlined to get xmalloc() from system.h for consistent malloc fail behavior - convert callers for new behavior, apart from some debug fprintf()'s
Diffstat (limited to 'rpmio')
-rw-r--r--rpmio/rpmpgp.c12
-rw-r--r--rpmio/rpmpgp.h12
2 files changed, 13 insertions, 11 deletions
diff --git a/rpmio/rpmpgp.c b/rpmio/rpmpgp.c
index 03b369cac..7267345a4 100644
--- a/rpmio/rpmpgp.c
+++ b/rpmio/rpmpgp.c
@@ -204,10 +204,13 @@ static void pgpPrtStr(const char *pre, const char *s)
static void pgpPrtHex(const char *pre, const uint8_t *p, size_t plen)
{
+ char *hex = NULL;
if (!_print) return;
if (pre && *pre)
fprintf(stderr, "%s", pre);
- fprintf(stderr, " %s", pgpHexStr(p, plen));
+ hex = pgpHexStr(p, plen);
+ fprintf(stderr, " %s", hex);
+ free(hex);
}
void pgpPrtVal(const char * pre, pgpValTbl vs, uint8_t val)
@@ -640,6 +643,13 @@ static const char * const pgpSecretELGAMAL[] = {
};
#endif
+char * pgpHexStr(const uint8_t *p, size_t plen)
+{
+ char *t = xmalloc(plen * 2 + 1);
+ pgpHexCvt(t, p, plen);
+ return t;
+}
+
static const uint8_t * pgpPrtPubkeyParams(uint8_t pubkey_algo,
const uint8_t *p, const uint8_t *h, size_t hlen)
{
diff --git a/rpmio/rpmpgp.h b/rpmio/rpmpgp.h
index 6f7c50328..96e44ca8a 100644
--- a/rpmio/rpmpgp.h
+++ b/rpmio/rpmpgp.h
@@ -1049,19 +1049,11 @@ char * pgpHexCvt(char *t, const uint8_t *s, size_t nbytes)
/** \ingroup rpmpgp
* Return hex formatted representation of bytes.
- * @todo Remove static buffer.
* @param p bytes
* @param plen no. of bytes
- * @return hex formatted string
+ * @return hex formatted string (malloc'ed)
*/
-static inline
-const char * pgpHexStr(const uint8_t *p, size_t plen)
-{
- static char prbuf[8*BUFSIZ]; /* XXX ick */
- char *t = prbuf;
- t = pgpHexCvt(t, p, plen);
- return prbuf;
-}
+char * pgpHexStr(const uint8_t *p, size_t plen);
/** \ingroup rpmpgp
* Return hex formatted representation of a multiprecision integer.