]> granicus.if.org Git - apache/commitdiff
* Solve a chicken and egg problem here:
authorRuediger Pluem <rpluem@apache.org>
Mon, 18 Mar 2019 10:18:55 +0000 (10:18 +0000)
committerRuediger Pluem <rpluem@apache.org>
Mon, 18 Mar 2019 10:18:55 +0000 (10:18 +0000)
  We need to have sslconn->dc set correctly when we want to
  init sslconn, but we need to allocate memory for it first.

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

modules/ssl/mod_ssl.c

index 9a2e7460408f1b2c9f760697fbff7cd08d2f7cad..fa7aa067f78ad33fe18d79050df8ee8b6fc9cdec 100644 (file)
@@ -490,10 +490,25 @@ static SSLConnRec *ssl_init_connection_ctx(conn_rec *c,
                                            int new_proxy)
 {
     SSLConnRec *sslconn = myConnConfig(c);
+    int need_setup = 0;
 
     if (!sslconn) {
         sslconn = apr_pcalloc(c->pool, sizeof(*sslconn));
+        need_setup = 1;
+    }
+
+    /* Reinit dc in any case because it may be r->per_dir_config scoped
+     * and thus a caller like mod_proxy needs to update it per request.
+     */
+    if (per_dir_config) {
+        sslconn->dc = ap_get_module_config(per_dir_config, &ssl_module);
+    }
+    else {
+        sslconn->dc = ap_get_module_config(c->base_server->lookup_defaults,
+                                           &ssl_module);
+    }
 
+    if (need_setup) {
         sslconn->server = c->base_server;
         sslconn->verify_depth = UNSET;
         if (new_proxy) {
@@ -508,17 +523,6 @@ static SSLConnRec *ssl_init_connection_ctx(conn_rec *c,
         myConnConfigSet(c, sslconn);
     }
 
-    /* Reinit dc in any case because it may be r->per_dir_config scoped
-     * and thus a caller like mod_proxy needs to update it per request.
-     */
-    if (per_dir_config) {
-        sslconn->dc = ap_get_module_config(per_dir_config, &ssl_module);
-    }
-    else {
-        sslconn->dc = ap_get_module_config(c->base_server->lookup_defaults,
-                                           &ssl_module);
-    }
-
     return sslconn;
 }