From 3e76c5767afb48fd81a743bd0bc102eba0b2b611 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Mon, 24 Mar 2008 23:58:43 +0200 Subject: [PATCH] Avoid couple of static buffers in psm script functions --- lib/psm.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/psm.c b/lib/psm.c index cb53957..3754e71 100644 --- a/lib/psm.c +++ b/lib/psm.c @@ -13,6 +13,7 @@ #include /* rpmMkTempFile() */ #include /* XXX for db_chrootDone */ #include +#include #include "rpmio/rpmlua.h" #include "lib/cpio.h" @@ -546,13 +547,14 @@ static rpmRC runLuaScript(rpmpsm psm, Header h, rpmTag stag, rpmluaPop(lua); { - char buf[BUFSIZ]; - xx = snprintf(buf, BUFSIZ, "%s(%s-%s-%s)", sln, n, v, r); + char *buf = NULL; + rasprintf(&buf, "%s(%s-%s-%s)", sln, n, v, r); if (rpmluaRunScript(lua, script, buf) == -1) { void * ptr; ptr = rpmtsNotify(ts, psm->te, RPMCALLBACK_SCRIPT_ERROR, stag, 1); rc = RPMRC_FAIL; } + free(buf); } rpmluaDelVar(lua, "arg"); @@ -799,13 +801,15 @@ static rpmRC runScript(rpmpsm psm, Header h, rpmTag stag, if (prefixes != NULL) for (i = 0; i < numPrefixes; i++) { - sprintf(prefixBuf, "RPM_INSTALL_PREFIX%d=%s", i, prefixes[i]); + rasprintf(&prefixBuf, "RPM_INSTALL_PREFIX%d=%s", i, prefixes[i]); xx = doputenv(prefixBuf); + prefixBuf = _free(prefixBuf); /* backwards compatibility */ if (i == 0) { - sprintf(prefixBuf, "RPM_INSTALL_PREFIX=%s", prefixes[i]); + rasprintf(&prefixBuf, "RPM_INSTALL_PREFIX=%s", prefixes[i]); xx = doputenv(prefixBuf); + prefixBuf = _free(prefixBuf); } } -- 2.7.4