Minimally convert all pgpHexCvt() users to use pgpHexStr() instead
authorPanu Matilainen <pmatilai@redhat.com>
Mon, 7 Apr 2008 10:26:46 +0000 (13:26 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Mon, 7 Apr 2008 10:26:46 +0000 (13:26 +0300)
lib/signature.c
rpmio/rpmpgp.h
tools/debugedit.c

index ddf947f..195e83d 100644 (file)
@@ -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;
index 96e44ca..05e1450 100644 (file)
@@ -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;
 }
 
index 6699c76..c298cd2 100644 (file)
@@ -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);
   }
 }