From 000e842f7d11e9ae2fdbd93a21b04d3d993ae7e0 Mon Sep 17 00:00:00 2001 From: Thierry Fournier Date: Thu, 21 Jan 2016 09:30:18 +0100 Subject: BUG/MINOR: lua: unsafe initialization During the Lua HAProxy initialisation, C functions using Lua calls can throws an error. This error was not catched. This patch fix this behaviour. (cherry picked from commit 75933d48fe257d8223e99af96b5f903b34b3d40a) --- src/hlua.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/hlua.c b/src/hlua.c index d70b01b..2985530 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -6529,6 +6529,12 @@ void hlua_init(void) /* Initialise lua. */ luaL_openlibs(gL.T); + /* Set safe environment for the initialisation. */ + if (!SET_SAFE_LJMP(gL.T)) { + fprintf(stderr, "Lua init: critical error.\n"); + exit(1); + } + /* * * Create "core" object. @@ -7085,4 +7091,6 @@ void hlua_init(void) /* Initialize SSL server. */ ssl_sock_prepare_srv_ctx(&socket_ssl, &socket_proxy); #endif + + RESET_SAFE_LJMP(gL.T); } -- 1.7.12.1