perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Philippe M. Chiasson" <go...@ectoplasm.org>
Subject [Patch] Prevent coredump when statically linked module tries to access ap_server_config_defines from register_hooks
Date Tue, 15 Jun 2004 23:36:34 GMT
The only moment where it's appropriate for a module to push Defines values into
ap_server_config_defines is during the register_hook phase. The problem is that
this phase is called earlier for compiled-in modules than for loaded modules.
So a module trying to add to it thru apr_array_push(ap_server_config_defines) at
that time will succeed, only if it's dynamically loaded, and most likely segfault
otherwise.

The following patches delays ap_setup_prelinked_modules to slightly later, after
ap_server_config_defines has been proprely initialized.

Index: server/main.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/server/main.c,v
retrieving revision 1.157
diff -u -I$Id -r1.157 main.c
--- server/main.c	25 Apr 2004 17:23:31 -0000	1.157
+++ server/main.c	15 Jun 2004 23:33:28 -0000
@@ -428,18 +428,18 @@
      }
  #endif

+    apr_pool_create(&pcommands, pglobal);
+    apr_pool_tag(pcommands, "pcommands");
+    ap_server_pre_read_config  = apr_array_make(pcommands, 1, sizeof(char *));
+    ap_server_post_read_config = apr_array_make(pcommands, 1, sizeof(char *));
+    ap_server_config_defines   = apr_array_make(pcommands, 1, sizeof(char *));
+
      error = ap_setup_prelinked_modules(process);
      if (error) {
          ap_log_error(APLOG_MARK, APLOG_STARTUP|APLOG_EMERG, 0, NULL, "%s: %s",
                       ap_server_argv0, error);
          destroy_and_exit_process(process, 1);
      }
-
-    apr_pool_create(&pcommands, pglobal);
-    apr_pool_tag(pcommands, "pcommands");
-    ap_server_pre_read_config  = apr_array_make(pcommands, 1, sizeof(char *));
-    ap_server_post_read_config = apr_array_make(pcommands, 1, sizeof(char *));
-    ap_server_config_defines   = apr_array_make(pcommands, 1, sizeof(char *));

      ap_run_rewrite_args(process);



-- 
--------------------------------------------------------------------------------
Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID : 88C3A5A5
http://gozer.ectoplasm.org/     F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3A5A5

Mime
View raw message