summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2017-04-13 15:43:11 +0300
committerPanu Matilainen <pmatilai@redhat.com>2017-04-13 15:43:11 +0300
commit280a9d9c9a0a52a4582f4b38ec5e95520db383c7 (patch)
tree8d91ad54c4a632c06e64601ee74d21c710db600e
parent1e28f6ca7591511c7c0a8a325a01cb3b44e144c6 (diff)
downloadrpm-280a9d9c9a0a52a4582f4b38ec5e95520db383c7.tar.gz
Consolidate OpenPGP time debug printing into a helper function
-rw-r--r--rpmio/rpmpgp.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/rpmio/rpmpgp.c b/rpmio/rpmpgp.c
index b0678a0ed..639ee46df 100644
--- a/rpmio/rpmpgp.c
+++ b/rpmio/rpmpgp.c
@@ -248,6 +248,19 @@ static void pgpPrtVal(const char * pre, pgpValTbl vs, uint8_t val)
fprintf(stderr, "%s(%u)", pgpValStr(vs, val), (unsigned)val);
}
+static void pgpPrtTime(const char * pre, const uint8_t *p, size_t plen)
+{
+ if (!_print) return;
+ if (pre && *pre)
+ fprintf(stderr, "%s", pre);
+ if (plen == 4) {
+ time_t t = pgpGrab(p, plen);
+ fprintf(stderr, " %-24.24s(0x%08x)", ctime(&t), (unsigned)t);
+ } else {
+ pgpPrtHex("", p+1, plen-1);
+ }
+}
+
/** \ingroup rpmpgp
* Return hex formatted representation of a multiprecision integer.
* @param p bytes
@@ -439,12 +452,7 @@ static int pgpPrtSubType(const uint8_t *h, size_t hlen, pgpSigType sigtype,
}
case PGPSUBTYPE_SIG_EXPIRE_TIME:
case PGPSUBTYPE_KEY_EXPIRE_TIME:
- if ((plen - 1) == 4) {
- time_t t = pgpGrab(p+1, plen-1);
- if (_print)
- fprintf(stderr, " %-24.24s(0x%08x)", ctime(&t), (unsigned)t);
- } else
- pgpPrtHex("", p+1, plen-1);
+ pgpPrtTime(" ", p+1, plen-1);
break;
case PGPSUBTYPE_ISSUER_KEYID: /* issuer key ID */
@@ -563,7 +571,6 @@ static int pgpPrtSig(pgpTag tag, const uint8_t *h, size_t hlen,
switch (version) {
case 3:
{ pgpPktSigV3 v = (pgpPktSigV3)h;
- time_t t;
if (hlen <= sizeof(*v) || v->hashlen != 5)
return 1;
@@ -573,9 +580,7 @@ static int pgpPrtSig(pgpTag tag, const uint8_t *h, size_t hlen,
pgpPrtVal(" ", pgpHashTbl, v->hash_algo);
pgpPrtVal(" ", pgpSigTypeTbl, v->sigtype);
pgpPrtNL();
- t = pgpGrab(v->time, sizeof(v->time));
- if (_print)
- fprintf(stderr, " %-24.24s(0x%08x)", ctime(&t), (unsigned)t);
+ pgpPrtTime(" ", v->time, sizeof(v->time));
pgpPrtNL();
pgpPrtHex(" signer keyid", v->signid, sizeof(v->signid));
plen = pgpGrab(v->signhash16, sizeof(v->signhash16));
@@ -716,7 +721,6 @@ static int pgpPrtKey(pgpTag tag, const uint8_t *h, size_t hlen,
{
uint8_t version = 0;
const uint8_t * p = NULL;
- time_t t;
int rc = 1;
if (pgpVersion(h, hlen, &version))
@@ -730,9 +734,7 @@ static int pgpPrtKey(pgpTag tag, const uint8_t *h, size_t hlen,
if (hlen > sizeof(*v)) {
pgpPrtVal("V4 ", pgpTagTbl, tag);
pgpPrtVal(" ", pgpPubkeyTbl, v->pubkey_algo);
- t = pgpGrab(v->time, sizeof(v->time));
- if (_print)
- fprintf(stderr, " %-24.24s(0x%08x)", ctime(&t), (unsigned)t);
+ pgpPrtTime(" ", v->time, sizeof(v->time));
pgpPrtNL();
/* If _digp->hash is not NULL then signature is already loaded */