diff options
-rw-r--r-- | lib/signature.c | 21 | ||||
-rw-r--r-- | rpmio/rpmpgp.h | 6 | ||||
-rw-r--r-- | tools/debugedit.c | 4 |
3 files changed, 17 insertions, 14 deletions
diff --git a/lib/signature.c b/lib/signature.c index ddf947fe1..195e83d03 100644 --- a/lib/signature.c +++ b/lib/signature.c @@ -989,7 +989,7 @@ verifyMD5Signature(const rpmts ts, char ** msg, rpmRC res; uint8_t * md5sum = NULL; size_t md5len = 0; - char * t; + char * t, *md5; *msg = xmalloc(BUFSIZ); /* XXX FIXME, calculate string size instead */ t = *msg; @@ -1009,19 +1009,20 @@ verifyMD5Signature(const rpmts ts, char ** msg, rpmtsOp(ts, RPMTS_OP_DIGEST)->count--; /* XXX one too many */ if (md5len != siglen || memcmp(md5sum, sig, md5len)) { + char *hex = pgpHexStr(sig, siglen); res = RPMRC_FAIL; t = stpcpy(t, rpmSigString(res)); t = stpcpy(t, " Expected("); - (void) pgpHexCvt(t, sig, siglen); - t += strlen(t); + t = stpcpy(t, hex); t = stpcpy(t, ") != ("); } else { res = RPMRC_OK; t = stpcpy(t, rpmSigString(res)); t = stpcpy(t, " ("); } - (void) pgpHexCvt(t, md5sum, md5len); - t += strlen(t); + md5 = pgpHexStr(md5sum, md5len); + t = stpcpy(t, md5); + free(md5); t = stpcpy(t, ")"); exit: @@ -1246,9 +1247,10 @@ verifyRSASignature(rpmts ts, char ** msg, exit: t = stpcpy(t, rpmSigString(res)); if (sigp != NULL) { + char * signid = pgpHexStr(sigp->signid+4, sizeof(sigp->signid)-4); t = stpcpy(t, ", key ID "); - (void) pgpHexCvt(t, sigp->signid+4, sizeof(sigp->signid)-4); - t += strlen(t); + t = stpcpy(t, signid); + free(signid); } t = stpcpy(t, "\n"); return res; @@ -1348,9 +1350,10 @@ verifyDSASignature(rpmts ts, char ** msg, exit: t = stpcpy(t, rpmSigString(res)); if (sigp != NULL) { + char *signid = pgpHexStr(sigp->signid+4, sizeof(sigp->signid)-4); t = stpcpy(t, ", key ID "); - (void) pgpHexCvt(t, sigp->signid+4, sizeof(sigp->signid)-4); - t += strlen(t); + t = stpcpy(t, signid); + free(signid); } t = stpcpy(t, "\n"); return res; diff --git a/rpmio/rpmpgp.h b/rpmio/rpmpgp.h index 96e44ca8a..05e1450cd 100644 --- a/rpmio/rpmpgp.h +++ b/rpmio/rpmpgp.h @@ -1066,9 +1066,9 @@ const char * pgpMpiStr(const uint8_t *p) { static char prbuf[8*BUFSIZ]; /* XXX ick */ char *t = prbuf; - sprintf(t, "[%4u]: ", pgpGrab(p, (size_t) 2)); - t += strlen(t); - t = pgpHexCvt(t, p+2, pgpMpiLen(p)-2); + char *hex = pgpHexStr(p+2, pgpMpiLen(p)-2); + sprintf(t, "[%4u]: %s", pgpGrab(p, (size_t) 2), hex); + free(hex); return prbuf; } diff --git a/tools/debugedit.c b/tools/debugedit.c index 6699c76f4..c298cd295 100644 --- a/tools/debugedit.c +++ b/tools/debugedit.c @@ -1413,9 +1413,9 @@ handle_build_id (DSO *dso, Elf_Data *build_id, /* Now format the build ID bits in hex to print out. */ { const uint8_t * id = (uint8_t *)build_id->d_buf + build_id_offset; - char hex[build_id_size * 2 + 1]; - pgpHexCvt(hex, id, build_id_size); + char *hex = pgpHexStr(id, build_id_size); puts (hex); + free(hex); } } |