Meanwhile I have created a patch (for apache2handler against php-5.1.4)
where I allocate a new config entry in merge_php_config. Since I do not
have much experience with zend_hash_* functions someone should look at
it, get the idea and fix it / enhance it for apache2filter. I have no
checks done, if this is leaking or whatever... at least the
configuration parameters do not get scrambled anymore in my test
environment.
- mike
Mike Bretz wrote:
Hello,
i have discussed with rasmus in january 2005(!) a potential bug in
PHP4's merge_php_config function without finding a real solution /
reason for what I have monitored.
Now, today I had experienced the same strange things as last year,
using current PHP5 implementation.
The story is, that when using different
<DirectoryMatch></directoryMatch> parameters in a httpd.conf file
containing different php_value directives, the chances are good that
those values will mix up.
Reading the current mod_example.c from apache2 I can see following
comments:
[...]
* Note that while the per-directory and per-server configuration
records are
* available to most of the module handlers, they should be treated as
* READ-ONLY by all except the command and merge handlers.
Sometimes handlers
* are handed a record that applies to the current location by
implication or
* inheritance, and modifying it will change the rules for other
locations.
[...]
and for x_merge_dir_config there is:
[...]
* The routine MUST NOT modify any of its arguments!
[...]
Read (as in the example): It has to return a new allocated /
initialized config object.
BUT if you look at sapi/apache2handler/apache_config.c (and
sapi/apache2filter/apache_config.c)
you can see that the third parameter is actually CHANGED with
zend_hash_update and returned by the function (where this function HAS
to return a new allocated config!)
Who thinks that I am right that this is wrong implemented?
Who is able to make a patch for this?
-mike
--
mike peter bretz metropolis ag / entwicklung
email: [EMAIL PROTECTED] heinestraße 72
phone: +49-7121-348-120 d-72762 reutlingen
fax: +49-7121-348-111 http://www.metropolis-ag.de/
metropolis ag. creating social internetworks.
diff -uw php-5.1.4.orig/sapi/apache2handler/apache_config.c
php-5.1.4/sapi/apache2handler/apache_config.c
--- php-5.1.4.orig/sapi/apache2handler/apache_config.c 2006-01-01
13:50:18.000000000 +0100
+++ php-5.1.4/sapi/apache2handler/apache_config.c 2006-06-06
23:34:48.000000000 +0200
@@ -118,14 +118,18 @@
void *merge_php_config(apr_pool_t *p, void *base_conf, void *new_conf)
{
- php_conf_rec *d = base_conf, *e = new_conf;
+ php_conf_rec *d = base_conf, *e;
+
php_dir_entry *pe;
php_dir_entry *data;
char *str;
uint str_len;
ulong num_index;
- phpapdebug((stderr, "Merge dir (%p) (%p)\n", base_conf, new_conf));
+ e = create_php_config(p, "merge_php_config");
+ zend_hash_copy(&e->config, &((php_conf_rec*)new_conf)->config, NULL,
NULL, sizeof(*data));
+
+ phpapdebug((stderr, "Merge dir (%p) (%p)\n", base_conf, e));
for (zend_hash_internal_pointer_reset(&d->config);
zend_hash_get_current_key_ex(&d->config, &str,
&str_len,
&num_index, 0, NULL) == HASH_KEY_IS_STRING;
@@ -138,7 +142,7 @@
zend_hash_update(&e->config, str, str_len, data, sizeof(*data),
NULL);
phpapdebug((stderr, "ADDING/OVERWRITING %s (%d vs. %d)\n", str,
data->status, pe?pe->status:-1));
}
- return new_conf;
+ return e;
}
char *get_php_config(void *conf, char *name, size_t name_len)
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php