]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: lua: unsafe initialization
authorThierry Fournier <tfournier@arpalert.org>
Thu, 21 Jan 2016 08:30:18 +0000 (09:30 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 11 Feb 2016 18:30:19 +0000 (19:30 +0100)
During the Lua HAProxy initialisation, C functions using Lua calls
can throws an error. This error was not catched. This patch fix
this behaviour.

src/hlua.c

index 5cf23203fc6e40bfc8de5101e122f32e88eca35d..1a31eb267d34b93c32a93d562296b6a9aecfbecf 100644 (file)
@@ -6591,6 +6591,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.
@@ -7151,4 +7157,6 @@ void hlua_init(void)
        /* Initialize SSL server. */
        ssl_sock_prepare_srv_ctx(&socket_ssl, &socket_proxy);
 #endif
+
+       RESET_SAFE_LJMP(gL.T);
 }