You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by fu...@apache.org on 2013/04/14 04:53:36 UTC

svn commit: r1467721 - /httpd/httpd/trunk/modules/lua/lua_request.c

Author: fuankg
Date: Sun Apr 14 02:53:36 2013
New Revision: 1467721

URL: http://svn.apache.org/r1467721
Log:
Return early with an error instead of returning an incomplete match table.

Modified:
    httpd/httpd/trunk/modules/lua/lua_request.c

Modified: httpd/httpd/trunk/modules/lua/lua_request.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/lua/lua_request.c?rev=1467721&r1=1467720&r2=1467721&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/lua/lua_request.c (original)
+++ httpd/httpd/trunk/modules/lua/lua_request.c Sun Apr 14 02:53:36 2013
@@ -921,6 +921,16 @@ static int lua_ap_regex(lua_State *L)
         return 2;
     }
 
+    if (regex.re_nsub > MODLUA_MAX_REG_MATCH) {
+        lua_pushboolean(L, 0);
+        err = apr_palloc(r->pool, 64);
+        apr_snprintf(err, 64,
+                     "regcomp found %d matches; only %d allowed.",
+                     regex.re_nsub, MODLUA_MAX_REG_MATCH);
+        lua_pushstring(L, err);
+        return 2;
+    }
+
     rv = ap_regexec(&regex, source, MODLUA_MAX_REG_MATCH, matches, 0);
     if (rv == AP_REG_NOMATCH) {
         lua_pushboolean(L, 0);
@@ -928,7 +938,7 @@ static int lua_ap_regex(lua_State *L)
     }
     
     lua_newtable(L);
-    for (i = 0; i <= regex.re_nsub && i <= MODLUA_MAX_REG_MATCH; i++) {
+    for (i = 0; i <= regex.re_nsub; i++) {
         lua_pushinteger(L, i);
         if (matches[i].rm_so >= 0 && matches[i].rm_eo >= 0)
             lua_pushstring(L,