components/apache2-modules/mod_security2/patches/fix_lua.patch
changeset 1212 207ff3b0329a
parent 1028 30d7999e80d9
equal deleted inserted replaced
1211:72f88619e71d 1212:207ff3b0329a
     1 --- modsecurity-apache_2.5.9/apache2/msc_lua.c.orig	2012-10-22 05:18:52.549922682 -0700
     1 https://github.com/SpiderLabs/ModSecurity/commit/452177c437cdefeb6e8b773b5865af356a1c9e2d.patch
     2 +++ modsecurity-apache_2.5.9/apache2/msc_lua.c	2012-10-22 05:21:37.503228311 -0700
     2 
     3 @@ -81,7 +81,11 @@
     3 From 452177c437cdefeb6e8b773b5865af356a1c9e2d Mon Sep 17 00:00:00 2001
     4      dumpr.script = script;
     4 From: Breno Silva <[email protected]>
     5      dumpr.index = 0;
     5 Date: Wed, 30 Jan 2013 22:04:21 -0400
       
     6 Subject: [PATCH] ModSecurity: fixed compiling with lua 5.2
       
     7 
       
     8 ---
       
     9  apache2/mod_security2.c |    4 ++++
       
    10  apache2/msc_lua.c       |   17 +++++++++++++++++
       
    11  2 files changed, 21 insertions(+)
       
    12 
       
    13 diff --git a/apache2/mod_security2.c b/apache2/mod_security2.c
       
    14 index 6b41088..849ca9d 100644
       
    15 --- a/apache2/mod_security2.c
       
    16 +++ b/apache2/mod_security2.c
       
    17 @@ -440,7 +440,11 @@ static modsec_rec *create_tx_context(request_rec *r) {
     6  
    18  
     7 +#if LUA_VERSION_NUM >= 502
    19  #if defined(WITH_LUA)
     8 +    return lua_load(L, dump_reader, &dumpr, script->name, NULL);
    20      #ifdef CACHE_LUA
       
    21 +#if LUA_VERSION_NUM > 501
       
    22 +    msr->L = luaL_newstate();
     9 +#else
    23 +#else
    10      return lua_load(L, dump_reader, &dumpr, script->name);
    24      msr->L = lua_open();
    11 +#endif
    25 +#endif
    12  }
    26      luaL_openlibs(msr->L);
       
    27      #endif
       
    28  #endif
       
    29 diff --git a/apache2/msc_lua.c b/apache2/msc_lua.c
       
    30 index 4abf7e5..6450e77 100644
       
    31 --- a/apache2/msc_lua.c
       
    32 +++ b/apache2/msc_lua.c
       
    33 @@ -94,7 +94,11 @@ char *lua_compile(msc_script **script, const char *filename, apr_pool_t *pool) {
       
    34      msc_lua_dumpw_t dump;
    13  
    35  
    14  /**
    36      /* Initialise state. */
       
    37 +#if LUA_VERSION_NUM > 501
       
    38 +    L = luaL_newstate();
       
    39 +#else
       
    40      L = lua_open();
       
    41 +#endif
       
    42      luaL_openlibs(L);
       
    43  
       
    44      /* Find script. */
       
    45 @@ -158,7 +162,11 @@ static apr_array_header_t *resolve_tfns(lua_State *L, int idx, modsec_rec *msr,
       
    46      if (lua_isuserdata(L, idx) || lua_isnoneornil(L, idx)) { /* No second parameter */
       
    47          return tfn_arr;
       
    48      } else if (lua_istable(L, idx)) { /* Is the second parameter an array? */
       
    49 +#if LUA_VERSION_NUM > 501
       
    50 +        int i, n = lua_rawlen(L, idx);
       
    51 +#else
       
    52          int i, n = lua_objlen(L, idx);
       
    53 +#endif
       
    54  
       
    55          for(i = 1; i <= n; i++) {
       
    56              lua_rawgeti(L, idx, i);
       
    57 @@ -415,7 +423,11 @@ int lua_execute(msc_script *script, char *param, modsec_rec *msr, msre_rule *rul
       
    58          lua_pop(L, rc);
       
    59  #else
       
    60      /* Create new state. */
       
    61 +#if LUA_VERSION_NUM > 501
       
    62 +    L = luaL_newstate();
       
    63 +#else
       
    64      L = lua_open();
       
    65 +#endif
       
    66      luaL_openlibs(L);
       
    67  #endif
       
    68  
       
    69 @@ -433,7 +445,12 @@ int lua_execute(msc_script *script, char *param, modsec_rec *msr, msre_rule *rul
       
    70      }
       
    71  
       
    72      /* Register functions. */
       
    73 +#if LUA_VERSION_NUM > 501
       
    74 +    luaL_setfuncs(L,mylib,0);
       
    75 +    lua_setglobal(L,"m");
       
    76 +#else
       
    77      luaL_register(L, "m", mylib);
       
    78 +#endif
       
    79  
       
    80      rc = lua_restore(L, script);
       
    81      if (rc) {
       
    82 -- 
       
    83 1.7.10
       
    84