Bug in apache_config.c / merge_php_config

php.internals

Mike Bretz

20 years ago
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: m.bretz@metropolis-ag.de 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.

Mike Bretz

20 years ago
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: m.bretz@metropolis-ag.de 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.