mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-30 03:34:29 +03:00
ModSecurity: fixed compiling with lua 5.2
This commit is contained in:
@@ -440,7 +440,11 @@ static modsec_rec *create_tx_context(request_rec *r) {
|
|||||||
|
|
||||||
#if defined(WITH_LUA)
|
#if defined(WITH_LUA)
|
||||||
#ifdef CACHE_LUA
|
#ifdef CACHE_LUA
|
||||||
|
#if LUA_VERSION_NUM > 501
|
||||||
|
msr->L = luaL_newstate();
|
||||||
|
#else
|
||||||
msr->L = lua_open();
|
msr->L = lua_open();
|
||||||
|
#endif
|
||||||
luaL_openlibs(msr->L);
|
luaL_openlibs(msr->L);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
@@ -94,7 +94,11 @@ char *lua_compile(msc_script **script, const char *filename, apr_pool_t *pool) {
|
|||||||
msc_lua_dumpw_t dump;
|
msc_lua_dumpw_t dump;
|
||||||
|
|
||||||
/* Initialise state. */
|
/* Initialise state. */
|
||||||
|
#if LUA_VERSION_NUM > 501
|
||||||
|
L = luaL_newstate();
|
||||||
|
#else
|
||||||
L = lua_open();
|
L = lua_open();
|
||||||
|
#endif
|
||||||
luaL_openlibs(L);
|
luaL_openlibs(L);
|
||||||
|
|
||||||
/* Find script. */
|
/* Find script. */
|
||||||
@@ -158,7 +162,11 @@ static apr_array_header_t *resolve_tfns(lua_State *L, int idx, modsec_rec *msr,
|
|||||||
if (lua_isuserdata(L, idx) || lua_isnoneornil(L, idx)) { /* No second parameter */
|
if (lua_isuserdata(L, idx) || lua_isnoneornil(L, idx)) { /* No second parameter */
|
||||||
return tfn_arr;
|
return tfn_arr;
|
||||||
} else if (lua_istable(L, idx)) { /* Is the second parameter an array? */
|
} else if (lua_istable(L, idx)) { /* Is the second parameter an array? */
|
||||||
|
#if LUA_VERSION_NUM > 501
|
||||||
|
int i, n = lua_rawlen(L, idx);
|
||||||
|
#else
|
||||||
int i, n = lua_objlen(L, idx);
|
int i, n = lua_objlen(L, idx);
|
||||||
|
#endif
|
||||||
|
|
||||||
for(i = 1; i <= n; i++) {
|
for(i = 1; i <= n; i++) {
|
||||||
lua_rawgeti(L, idx, i);
|
lua_rawgeti(L, idx, i);
|
||||||
@@ -415,7 +423,11 @@ int lua_execute(msc_script *script, char *param, modsec_rec *msr, msre_rule *rul
|
|||||||
lua_pop(L, rc);
|
lua_pop(L, rc);
|
||||||
#else
|
#else
|
||||||
/* Create new state. */
|
/* Create new state. */
|
||||||
|
#if LUA_VERSION_NUM > 501
|
||||||
|
L = luaL_newstate();
|
||||||
|
#else
|
||||||
L = lua_open();
|
L = lua_open();
|
||||||
|
#endif
|
||||||
luaL_openlibs(L);
|
luaL_openlibs(L);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -433,7 +445,12 @@ int lua_execute(msc_script *script, char *param, modsec_rec *msr, msre_rule *rul
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Register functions. */
|
/* Register functions. */
|
||||||
|
#if LUA_VERSION_NUM > 501
|
||||||
|
luaL_setfuncs(L,mylib,0);
|
||||||
|
lua_setglobal(L,"m");
|
||||||
|
#else
|
||||||
luaL_register(L, "m", mylib);
|
luaL_register(L, "m", mylib);
|
||||||
|
#endif
|
||||||
|
|
||||||
rc = lua_restore(L, script);
|
rc = lua_restore(L, script);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
|
Reference in New Issue
Block a user