Don't use static buffers
authorJindrich Novy <jnovy@redhat.com>
Sun, 20 Apr 2008 10:17:37 +0000 (12:17 +0200)
committerJindrich Novy <jnovy@redhat.com>
Sun, 20 Apr 2008 19:49:51 +0000 (21:49 +0200)
lib/psm.c
lib/rpmts.c

index 70f0c2a..8179b64 100644 (file)
--- a/lib/psm.c
+++ b/lib/psm.c
@@ -125,7 +125,7 @@ const char ** argv;
        const char * str;
        int32_t * i32p;
     } body;
-    char numbuf[32];
+    char *numbuf = NULL;
     rpmTagType type;
 
     for (tagm = tagMacros; tagm->macroname != NULL; tagm++) {
@@ -133,8 +133,9 @@ const char ** argv;
            continue;
        switch (type) {
        case RPM_INT32_TYPE:
-           sprintf(numbuf, "%d", *body.i32p);
+           rasprintf(&numbuf, "%d", *body.i32p);
            addMacro(NULL, tagm->macroname, NULL, numbuf, -1);
+           numbuf = _free(numbuf);
            break;
        case RPM_STRING_TYPE:
            addMacro(NULL, tagm->macroname, NULL, body.str, -1);
index 9066743..290359b 100644 (file)
@@ -312,9 +312,7 @@ fprintf(stderr, "*** free pkt %p[%d] id %08x %08x\n", ts->pkpkt, ts->pkpktlen, p
        mi = rpmdbFreeIterator(mi);
 
        if (ix >= 0) {
-           char hnum[32];
-           sprintf(hnum, "h#%d", hx);
-           pubkeysource = xstrdup(hnum);
+           rasprintf(&pubkeysource, "h#%d", hx);
        } else {
            ts->pkpkt = _free(ts->pkpkt);
            ts->pkpktlen = 0;