Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:43706 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 63102 invoked from network); 14 Apr 2009 23:22:51 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Apr 2009 23:22:51 -0000 Authentication-Results: pb1.pair.com header.from=stas@zend.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=stas@zend.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 63.205.162.116 as permitted sender) X-PHP-List-Original-Sender: stas@zend.com X-Host-Fingerprint: 63.205.162.116 us-gw1.zend.com Windows 2000 SP4, XP SP1 Received: from [63.205.162.116] ([63.205.162.116:65197] helo=us-gw1.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C8/E4-50915-ACA15E94 for ; Tue, 14 Apr 2009 19:22:51 -0400 Received: from [192.168.16.112] ([192.168.16.112]) by us-gw1.zend.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 14 Apr 2009 16:22:33 -0700 Message-ID: <49E51AC7.1010709@zend.com> Date: Tue, 14 Apr 2009 16:22:47 -0700 Organization: Zend Technologies User-Agent: Thunderbird 2.0.0.21 (Windows/20090302) MIME-Version: 1.0 To: 'PHP Internals' Content-Type: multipart/mixed; boundary="------------070004030508060500000000" X-OriginalArrivalTime: 14 Apr 2009 23:22:33.0658 (UTC) FILETIME=[E3B0A9A0:01C9BD57] Subject: proposed fix for ext/filter crash (bug #47930) From: stas@zend.com (Stanislav Malyshev) --------------070004030508060500000000 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi! I was looking at how to fix #47930 and unfortunately due to the fact that ext/filter is called before it's initialized as an extension, the only fix that I could think of requires change in the API. Please see attached. Please tell me if anybody sees any problem with it. -- Stanislav Malyshev, Zend Software Architect stas@zend.com http://www.zend.com/ (408)253-8829 MSN: stas@zend.com --------------070004030508060500000000 Content-Type: text/plain; name="filter.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="filter.diff" Index: ext/filter/filter.c =================================================================== RCS file: /repository/php-src/ext/filter/filter.c,v retrieving revision 1.52.2.39.2.15 diff -u -r1.52.2.39.2.15 filter.c --- ext/filter/filter.c 14 Apr 2009 14:18:35 -0000 1.52.2.39.2.15 +++ ext/filter/filter.c 14 Apr 2009 23:13:46 -0000 @@ -76,6 +76,7 @@ #endif static unsigned int php_sapi_filter(int arg, char *var, char **val, unsigned int val_len, unsigned int *new_val_len TSRMLS_DC); +static unsigned int php_sapi_filter_init(TSRMLS_D); /* {{{ arginfo */ ZEND_BEGIN_ARG_INFO_EX(arginfo_filter_input, 0, 0, 2) @@ -270,7 +271,7 @@ REGISTER_LONG_CONSTANT("FILTER_FLAG_NO_RES_RANGE", FILTER_FLAG_NO_RES_RANGE, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("FILTER_FLAG_NO_PRIV_RANGE", FILTER_FLAG_NO_PRIV_RANGE, CONST_CS | CONST_PERSISTENT); - sapi_register_input_filter(php_sapi_filter); + sapi_register_input_filter(php_sapi_filter, php_sapi_filter_init); return SUCCESS; } @@ -339,6 +340,17 @@ } /* }}} */ +static unsigned int php_sapi_filter_init(TSRMLS_D) +{ + IF_G(get_array) = NULL; + IF_G(post_array) = NULL; + IF_G(cookie_array) = NULL; + IF_G(server_array) = NULL; + IF_G(env_array) = NULL; + IF_G(session_array) = NULL; + return SUCCESS; +} + static void php_zval_filter(zval **value, long filter, long flags, zval *options, char* charset, zend_bool copy TSRMLS_DC) /* {{{ */ { filter_list_entry filter_func; Index: main/SAPI.c =================================================================== RCS file: /repository/php-src/main/SAPI.c,v retrieving revision 1.202.2.7.2.15.2.6 diff -u -r1.202.2.7.2.15.2.6 SAPI.c --- main/SAPI.c 31 Dec 2008 11:15:47 -0000 1.202.2.7.2.15.2.6 +++ main/SAPI.c 14 Apr 2009 23:13:49 -0000 @@ -326,6 +326,9 @@ sapi_module.activate(TSRMLS_C); } } + if (sapi_module.input_filter_init ) { + sapi_module.input_filter_init(TSRMLS_C); + } } /* @@ -392,6 +395,9 @@ sapi_module.activate(TSRMLS_C); } } + if (sapi_module.input_filter_init ) { + sapi_module.input_filter_init(TSRMLS_C); + } } @@ -925,13 +931,14 @@ return SUCCESS; } -SAPI_API int sapi_register_input_filter(unsigned int (*input_filter)(int arg, char *var, char **val, unsigned int val_len, unsigned int *new_val_len TSRMLS_DC)) +SAPI_API int sapi_register_input_filter(unsigned int (*input_filter)(int arg, char *var, char **val, unsigned int val_len, unsigned int *new_val_len TSRMLS_DC), unsigned int (*input_filter_init)(TSRMLS_D)) { TSRMLS_FETCH(); if (SG(sapi_started) && EG(in_execution)) { return FAILURE; } sapi_module.input_filter = input_filter; + sapi_module.input_filter_init = input_filter_init; return SUCCESS; } Index: main/SAPI.h =================================================================== RCS file: /repository/php-src/main/SAPI.h,v retrieving revision 1.114.2.1.2.3.2.7 diff -u -r1.114.2.1.2.3.2.7 SAPI.h --- main/SAPI.h 31 Dec 2008 17:33:05 -0000 1.114.2.1.2.3.2.7 +++ main/SAPI.h 14 Apr 2009 23:13:49 -0000 @@ -192,7 +192,7 @@ SAPI_API void sapi_unregister_post_entry(sapi_post_entry *post_entry TSRMLS_DC); SAPI_API int sapi_register_default_post_reader(void (*default_post_reader)(TSRMLS_D)); SAPI_API int sapi_register_treat_data(void (*treat_data)(int arg, char *str, zval *destArray TSRMLS_DC)); -SAPI_API int sapi_register_input_filter(unsigned int (*input_filter)(int arg, char *var, char **val, unsigned int val_len, unsigned int *new_val_len TSRMLS_DC)); +SAPI_API int sapi_register_input_filter(unsigned int (*input_filter)(int arg, char *var, char **val, unsigned int val_len, unsigned int *new_val_len TSRMLS_DC), unsigned int (*input_filter_init)(TSRMLS_D)); SAPI_API int sapi_flush(TSRMLS_D); SAPI_API struct stat *sapi_get_stat(TSRMLS_D); @@ -266,6 +266,7 @@ char *ini_entries; const zend_function_entry *additional_functions; + unsigned int (*input_filter_init)(TSRMLS_D); }; --------------070004030508060500000000--