httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From poir...@apache.org
Subject svn commit: r939987 - /httpd/httpd/trunk/modules/lua/mod_lua.c
Date Sat, 01 May 2010 12:04:27 GMT
Author: poirier
Date: Sat May  1 12:04:27 2010
New Revision: 939987

URL: http://svn.apache.org/viewvc?rev=939987&view=rev
Log:
Add info to debug logging.
Avoid null pointer dereference by returning if we can't get
a lua VM.
Move "we got a VM" message to after we know we have one.
Check that we found the lua handler function before trying to
call it.

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

Modified: httpd/httpd/trunk/modules/lua/mod_lua.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/lua/mod_lua.c?rev=939987&r1=939986&r2=939987&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/lua/mod_lua.c (original)
+++ httpd/httpd/trunk/modules/lua/mod_lua.c Sat May  1 12:04:27 2010
@@ -129,21 +129,32 @@ static int lua_handler(request_rec *r)
         }
 
         ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
-                      "request details scope:%u, cache:%u", d->spec->scope,
-                      d->spec->code_cache_style);
+                      "request details scope:%u, cache:%u, filename:%s, function:%s",
+                      d->spec->scope,
+                      d->spec->code_cache_style,
+                      d->spec->file,
+                      d->function_name);
         L = ap_lua_get_lua_state(r->pool,
                               d->spec,
                               cfg->package_paths,
                               cfg->package_cpaths,
                               &lua_open_callback, NULL);
 
-        ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "got a vm!");
         if (!L) {
             /* TODO annotate spec with failure reason */
             r->status = HTTP_INTERNAL_SERVER_ERROR;
             ap_rputs("Unable to compile VM, see logs", r);
+            return HTTP_INTERNAL_SERVER_ERROR;
         }
+        ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "got a vm!");
         lua_getglobal(L, d->function_name);
+        if (!lua_isfunction(L, -1)) {
+            ap_log_rerror(APLOG_MARK, APLOG_CRIT, 0, r,
+                          "lua: Unable to find function %s in %s",
+                          d->function_name,
+                          d->spec->file);
+            return HTTP_INTERNAL_SERVER_ERROR;
+        }
         ap_lua_run_lua_request(L, r);
         if (lua_pcall(L, 1, 0, 0)) {
             report_lua_error(L, r);



Mime
View raw message