]> granicus.if.org Git - apache/commitdiff
Prevent segfault if DYNAMIC_MODULE_LIMIT is reached
authorStefan Fritsch <sf@apache.org>
Fri, 15 Apr 2011 19:04:29 +0000 (19:04 +0000)
committerStefan Fritsch <sf@apache.org>
Fri, 15 Apr 2011 19:04:29 +0000 (19:04 +0000)
PR: 51072
Submitted by: Torsten Förtsch <torsten foertsch gmx net>

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1092787 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
server/config.c

diff --git a/CHANGES b/CHANGES
index 6e9b68ea96acc6fd0e0714b6721ab819d90fa844..a32c696262b19546fa3edfa57de011a24d64c3b6 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,9 @@
 
 Changes with Apache 2.3.12
 
+  *) core: Prevent segfault if DYNAMIC_MODULE_LIMIT is reached. PR 51072.
+     [Torsten Förtsch <torsten foertsch gmx net>]
+
   *) WinNT MPM: Improve robustness under heavy load.  [Jeff Trawick]
 
   *) MinGW build improvements.  PR 49535.  [John Vandenberg 
index 4e2b3c0d81611649f3441f8e7f0bff3e6c292435..85dd7093fa28239e9134793453bb2c677d247b18 100644 (file)
@@ -541,22 +541,17 @@ AP_DECLARE(const char *) ap_add_module(module *m, apr_pool_t *p,
                             m->name, m->version, MODULE_MAGIC_NUMBER_MAJOR);
     }
 
-    if (m->next == NULL) {
-        m->next = ap_top_module;
-        ap_top_module = m;
-    }
-
     if (m->module_index == -1) {
-        m->module_index = total_modules++;
-        dynamic_modules++;
-
-        if (dynamic_modules > DYNAMIC_MODULE_LIMIT) {
+        if (dynamic_modules >= DYNAMIC_MODULE_LIMIT) {
             return apr_psprintf(p, "Module \"%s\" could not be loaded, "
                                 "because the dynamic module limit was "
                                 "reached. Please increase "
                                 "DYNAMIC_MODULE_LIMIT and recompile.", m->name);
         }
 
+        m->module_index = total_modules++;
+        dynamic_modules++;
+
     }
     else if (!sym_name) {
         while (sym->modp != NULL) {
@@ -568,6 +563,11 @@ AP_DECLARE(const char *) ap_add_module(module *m, apr_pool_t *p,
         }
     }
 
+    if (m->next == NULL) {
+        m->next = ap_top_module;
+        ap_top_module = m;
+    }
+
     if (sym_name) {
         int len = strlen(sym_name);
         int slen = strlen("_module");