From 35ce3d32a9849aff39a7ffbbae84d7560c55eb14 Mon Sep 17 00:00:00 2001 From: rxi Date: Fri, 22 May 2020 08:11:05 +0100 Subject: [PATCH] Fixed string quoting on windows in `system.exec()` --- src/api/system.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/system.c b/src/api/system.c index fbb917ee..0215a564 100644 --- a/src/api/system.c +++ b/src/api/system.c @@ -335,10 +335,10 @@ static int f_sleep(lua_State *L) { static int f_exec(lua_State *L) { size_t len; const char *cmd = luaL_checklstring(L, 1, &len); - char *buf = malloc(len + 16); + char *buf = malloc(len + 32); if (!buf) { luaL_error(L, "buffer allocation failed"); } #if _WIN32 - sprintf(buf, "cmd /c %s", cmd); + sprintf(buf, "cmd /c \"%s\"", cmd); WinExec(buf, SW_HIDE); #else sprintf(buf, "%s &", cmd);