httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Trawick <traw...@attglobal.net>
Subject [PATCH] Re: Bugzilla bug 8034 - possible explanation of core dump (fwd)
Date Wed, 17 Apr 2002 12:57:33 GMT
Cliff Woolley <jwoolley@virginia.edu> writes:

> I've had this one bite me in the ass as well.  Same thing if you
> accidentally get duplicate LoadModule lines in there on a shared module,
> IIRC.  Would there ever be a *legitimate* reason to load the same module
> more than once?

It looks like mod_so already checks for duplicate LoadModule lines but
it doesn't check for a LoadModule which attempts to override a
built-in module.  The patch below seems to implement a check for this
second epossible error (a LoadModule directive for a built-in module).

Index: modules/mappers/mod_so.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/mappers/mod_so.c,v
retrieving revision 1.48
diff -u -r1.48 mod_so.c
--- modules/mappers/mod_so.c	16 Mar 2002 18:26:57 -0000	1.48
+++ modules/mappers/mod_so.c	17 Apr 2002 12:57:52 -0000
@@ -220,6 +220,7 @@
     /* 
      * 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);
@@ -233,6 +234,45 @@
             return NULL;
         }
     }
+
+    for (i = 0; ap_preloaded_modules[i]; i++) {
+        const char *preload_name;
+        apr_size_t preload_len;
+        apr_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 apr_pstrcat(cmd->pool, "module ", modname,
+                               " is built-in and can't be loaded",
+                               NULL);
+        }
+    }
+
     modi = apr_array_push(sconf->loaded_modules);
     modi->name = modname;
 

-- 
Jeff Trawick | trawick@attglobal.net
Born in Roswell... married an alien...

Mime
View raw message