You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2012/02/06 14:52:55 UTC

svn commit: r1241012 - /subversion/trunk/subversion/mod_dav_svn/mod_dav_svn.c

Author: stsp
Date: Mon Feb  6 13:52:54 2012
New Revision: 1241012

URL: http://svn.apache.org/viewvc?rev=1241012&view=rev
Log:
Allocate mod_dav_svn's hook environment in a persistent pool. Fixes crashes.

* subversion/mod_dav_svn/mod_dav_svn.c
  (create_dir_config): The pool passed here doesn't have sufficient lifetime
   for the hook environment hash. So don't allocate it here.
  (merge_dir_config): Handle NULL hook environments in parent and child configs.
  (SVNHooksEnv_cmd): Allocate the hook environment hash table here. Make sure
   that all strings are allocated in the same pool as the hash table.

Modified:
    subversion/trunk/subversion/mod_dav_svn/mod_dav_svn.c

Modified: subversion/trunk/subversion/mod_dav_svn/mod_dav_svn.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/mod_dav_svn/mod_dav_svn.c?rev=1241012&r1=1241011&r2=1241012&view=diff
==============================================================================
--- subversion/trunk/subversion/mod_dav_svn/mod_dav_svn.c (original)
+++ subversion/trunk/subversion/mod_dav_svn/mod_dav_svn.c Mon Feb  6 13:52:54 2012
@@ -195,7 +195,6 @@ create_dir_config(apr_pool_t *p, char *d
     conf->root_dir = svn_urlpath__canonicalize(dir, p);
   conf->bulk_updates = CONF_FLAG_ON;
   conf->v2_protocol = CONF_FLAG_ON;
-  conf->hooks_env = apr_hash_make(p);
 
   return conf;
 }
@@ -225,9 +224,14 @@ merge_dir_config(apr_pool_t *p, void *ba
   newconf->txdelta_cache = INHERIT_VALUE(parent, child, txdelta_cache);
   newconf->fulltext_cache = INHERIT_VALUE(parent, child, fulltext_cache);
   newconf->root_dir = INHERIT_VALUE(parent, child, root_dir);
-  newconf->hooks_env = apr_hash_merge(p, child->hooks_env, parent->hooks_env,
-                                      NULL /* child overrides parent */,
-                                      NULL /* unused data baton */);
+  if (child->hooks_env && parent->hooks_env)
+    newconf->hooks_env = apr_hash_merge(p, child->hooks_env, parent->hooks_env,
+                                        NULL /* child overrides parent */,
+                                        NULL /* unused data baton */);
+  else if (child->hooks_env)
+    newconf->hooks_env = child->hooks_env;
+  else if (parent->hooks_env)
+    newconf->hooks_env = parent->hooks_env;
 
   if (parent->fs_path)
     ap_log_error(APLOG_MARK, APLOG_WARNING, 0, NULL,
@@ -544,10 +548,15 @@ SVNHooksEnv_cmd(cmd_parms *cmd, void *co
     {
       dir_conf_t *conf = config;
 
+      if (!conf->hooks_env)
+        conf->hooks_env = apr_hash_make(cmd->pool);
+
       apr_hash_set(conf->hooks_env,
-                   APR_ARRAY_IDX(var, 0, const char *),
+                   apr_pstrdup(apr_hash_pool_get(conf->hooks_env),
+                     APR_ARRAY_IDX(var, 0, const char *)),
                    APR_HASH_KEY_STRING,
-                   APR_ARRAY_IDX(var, 1, const char *));
+                   apr_pstrdup(apr_hash_pool_get(conf->hooks_env),
+                     APR_ARRAY_IDX(var, 1, const char *)));
     }
 
   return NULL;