From 1f4b662ca5770eefef6b0b05c59e1d1b08ef2b3b Mon Sep 17 00:00:00 2001 From: Daniel Earl Poirier Date: Sat, 1 May 2010 12:04:27 +0000 Subject: [PATCH] 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. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@939987 13f79535-47bb-0310-9956-ffa450edef68 --- modules/lua/mod_lua.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/modules/lua/mod_lua.c b/modules/lua/mod_lua.c index 9c97a62587..e40df7c380 100644 --- a/modules/lua/mod_lua.c +++ b/modules/lua/mod_lua.c @@ -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); -- 2.40.0