From: Geoffrey Young Date: Wed, 8 Sep 2004 13:35:12 +0000 (+0000) Subject: Trigger an error when a LoadModule directive attempts to X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e881caa739415f447aab64e3e34409d21090b0a6;p=thirdparty%2Fapache%2Fhttpd.git Trigger an error when a LoadModule directive attempts to load a module which is built-in. This is a common error when switching from a DSO build to a static build. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x@105036 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/CHANGES b/src/CHANGES index 16bdde724bc..bf98def0476 100644 --- a/src/CHANGES +++ b/src/CHANGES @@ -1,5 +1,10 @@ Changes with Apache 1.3.32 + *) Trigger an error when a LoadModule directive attempts to + load a module which is built-in. This is a common error when + switching from a DSO build to a static build. + [Jeff Trawick, Geoffrey Young] + *) Fix trivial bug in mod_log_forensic that caused the child to seg fault when certain invalid requests were fired at it with forensic logging is enabled. PR 29313. diff --git a/src/modules/standard/mod_so.c b/src/modules/standard/mod_so.c index 6f7756f21d4..eb143e3acc3 100644 --- a/src/modules/standard/mod_so.c +++ b/src/modules/standard/mod_so.c @@ -182,6 +182,7 @@ static const char *load_module(cmd_parms *cmd, void *dummy, /* * check for already existing module * If it already exists, we have nothing to do + * Check both dynamically-loaded modules and statically-linked modules. */ sconf = (so_server_conf *)ap_get_module_config(cmd->server->module_config, &so_module); @@ -194,6 +195,45 @@ static const char *load_module(cmd_parms *cmd, void *dummy, return NULL; } } + + for (i = 0; ap_preloaded_modules[i]; i++) { + const char *preload_name; + size_t preload_len; + size_t thismod_len; + + modp = ap_preloaded_modules[i]; + + /* make sure we're comparing apples with apples + * make sure name of preloaded module is mod_FOO.c + * make sure name of structure being loaded is FOO_module + */ + + if (memcmp(modp->name, "mod_", 4)) { + continue; + } + + preload_name = modp->name + strlen("mod_"); + preload_len = strlen(preload_name) - 2; + + if (strlen(modname) <= strlen("_module")) { + continue; + } + thismod_len = strlen(modname) - strlen("_module"); + if (strcmp(modname + thismod_len, "_module")) { + continue; + } + + if (thismod_len != preload_len) { + continue; + } + + if (!memcmp(modname, preload_name, preload_len)) { + return ap_pstrcat(cmd->pool, "module ", modname, + " is built-in and can't be loaded", + NULL); + } + } + modi = ap_push_array(sconf->loaded_modules); modi->name = modname;