diff options
Diffstat (limited to 'rpmio/rpmlua.c')
-rw-r--r-- | rpmio/rpmlua.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/rpmio/rpmlua.c b/rpmio/rpmlua.c index 096a411a0..3345c5604 100644 --- a/rpmio/rpmlua.c +++ b/rpmio/rpmlua.c @@ -217,10 +217,19 @@ void rpmluaGetVar(rpmlua _lua, rpmluav var) #define FINDKEY_REMOVE 2 static int findkey(lua_State *L, int oper, const char *key, va_list va) { - char buf[BUFSIZ]; + char *buf; const char *s, *e; int ret = 0; - (void) vsnprintf(buf, sizeof(buf), key, va); + int blen; + + blen = vsnprintf(NULL, 0, key, va); + if (blen <= 0) { + return -1; + } + + buf = xmalloc(blen + 1); + vsnprintf(buf, blen + 1, key, va); + s = e = buf; lua_pushvalue(L, LUA_GLOBALSINDEX); for (;;) { @@ -263,6 +272,7 @@ static int findkey(lua_State *L, int oper, const char *key, va_list va) } e++; } + free(buf); return ret; } |