Yeah, it should probably be merged to head. --Wez.
Antony Dovgal wrote: > > MFB? Or HEAD doesn't need this patch? > > On 22.04.2006 21:17, Wez Furlong wrote: >> wez Sat Apr 22 17:17:40 2006 UTC >> >> Modified files: (Branch: PHP_5_1) >> /php-src NEWS /php-src/main/streams php_streams_int.h >> streams.c userspace.c Log: >> fix for #37158 >> >> http://cvs.php.net/viewcvs.cgi/php-src/NEWS?r1=1.2027.2.524&r2=1.2027.2.525&diff_format=u >> >> Index: php-src/NEWS >> diff -u php-src/NEWS:1.2027.2.524 php-src/NEWS:1.2027.2.525 >> --- php-src/NEWS:1.2027.2.524 Thu Apr 20 21:11:29 2006 >> +++ php-src/NEWS Sat Apr 22 17:17:40 2006 >> @@ -2,6 +2,8 @@ >> >> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| >> >> 20 Apr 2006, PHP 5.1.3RC3 >> - Fixed reading stream filters never notified about EOF. (Mike) >> +- Fixed bug #37158 (fread behaviour changes after calling >> + stream_wrapper_register). (Wez) >> - Fixed bug #37138 (__autoload tries to load callback'ed self and >> parent). >> (Dmitry) >> - Fixed bug #37103 (libmbfl headers not installed). (Jani) >> http://cvs.php.net/viewcvs.cgi/php-src/main/streams/php_streams_int.h?r1=1.7.2.1&r2=1.7.2.2&diff_format=u >> >> Index: php-src/main/streams/php_streams_int.h >> diff -u php-src/main/streams/php_streams_int.h:1.7.2.1 >> php-src/main/streams/php_streams_int.h:1.7.2.2 >> --- php-src/main/streams/php_streams_int.h:1.7.2.1 Sun Jan 1 >> 12:50:18 2006 >> +++ php-src/main/streams/php_streams_int.h Sat Apr 22 17:17:40 2006 >> @@ -16,7 +16,7 @@ >> >> +----------------------------------------------------------------------+ >> */ >> >> -/* $Id: php_streams_int.h,v 1.7.2.1 2006/01/01 12:50:18 sniper Exp $ */ >> +/* $Id: php_streams_int.h,v 1.7.2.2 2006/04/22 17:17:40 wez Exp $ */ >> >> >> #if ZEND_DEBUG >> @@ -46,7 +46,6 @@ >> >> #define STREAM_DEBUG 0 >> #define STREAM_WRAPPER_PLAIN_FILES ((php_stream_wrapper*)-1) >> -extern php_stream_wrapper php_plain_files_wrapper; >> >> #ifndef MAP_FAILED >> #define MAP_FAILED ((void *) -1) >> http://cvs.php.net/viewcvs.cgi/php-src/main/streams/streams.c?r1=1.82.2.5&r2=1.82.2.6&diff_format=u >> >> Index: php-src/main/streams/streams.c >> diff -u php-src/main/streams/streams.c:1.82.2.5 >> php-src/main/streams/streams.c:1.82.2.6 >> --- php-src/main/streams/streams.c:1.82.2.5 Thu Apr 20 17:43:18 2006 >> +++ php-src/main/streams/streams.c Sat Apr 22 17:17:40 2006 >> @@ -19,7 +19,7 @@ >> >> +----------------------------------------------------------------------+ >> */ >> >> -/* $Id: streams.c,v 1.82.2.5 2006/04/20 17:43:18 mike Exp $ */ >> +/* $Id: streams.c,v 1.82.2.6 2006/04/22 17:17:40 wez Exp $ */ >> >> #define _GNU_SOURCE >> #include "php.h" >> @@ -1457,7 +1457,7 @@ >> return FAILURE; >> } >> >> - return zend_hash_add(&url_stream_wrappers_hash, protocol, >> protocol_len, wrapper, sizeof(*wrapper), NULL); >> + return zend_hash_add(&url_stream_wrappers_hash, protocol, >> protocol_len, &wrapper, sizeof(wrapper), NULL); >> } >> >> PHPAPI int php_unregister_url_stream_wrapper(char *protocol TSRMLS_DC) >> @@ -1465,6 +1465,15 @@ >> return zend_hash_del(&url_stream_wrappers_hash, protocol, >> strlen(protocol)); >> } >> >> +static void clone_wrapper_hash(TSRMLS_D) >> +{ >> + php_stream_wrapper *tmp; >> + >> + ALLOC_HASHTABLE(FG(stream_wrappers)); >> + zend_hash_init(FG(stream_wrappers), 0, NULL, NULL, 1); >> + zend_hash_copy(FG(stream_wrappers), &url_stream_wrappers_hash, >> NULL, &tmp, sizeof(tmp)); >> +} >> + >> /* API for registering VOLATILE wrappers */ >> PHPAPI int php_register_url_stream_wrapper_volatile(char *protocol, >> php_stream_wrapper *wrapper TSRMLS_DC) >> { >> @@ -1475,24 +1484,16 @@ >> } >> >> if (!FG(stream_wrappers)) { >> - php_stream_wrapper tmpwrapper; >> - >> - ALLOC_HASHTABLE(FG(stream_wrappers)); >> - zend_hash_init(FG(stream_wrappers), 0, NULL, NULL, 1); >> - zend_hash_copy(FG(stream_wrappers), >> &url_stream_wrappers_hash, NULL, &tmpwrapper, >> sizeof(php_stream_wrapper)); >> + clone_wrapper_hash(TSRMLS_C); >> } >> >> - return zend_hash_add(FG(stream_wrappers), protocol, protocol_len, >> wrapper, sizeof(*wrapper), NULL); >> + return zend_hash_add(FG(stream_wrappers), protocol, protocol_len, >> &wrapper, sizeof(wrapper), NULL); >> } >> >> PHPAPI int php_unregister_url_stream_wrapper_volatile(char *protocol >> TSRMLS_DC) >> { >> if (!FG(stream_wrappers)) { >> - php_stream_wrapper tmpwrapper; >> - >> - ALLOC_HASHTABLE(FG(stream_wrappers)); >> - zend_hash_init(FG(stream_wrappers), 0, NULL, NULL, 1); >> - zend_hash_copy(FG(stream_wrappers), >> &url_stream_wrappers_hash, NULL, &tmpwrapper, >> sizeof(php_stream_wrapper)); >> + clone_wrapper_hash(TSRMLS_C); >> } >> >> return zend_hash_del(FG(stream_wrappers), protocol, >> strlen(protocol)); >> @@ -1503,7 +1504,7 @@ >> PHPAPI php_stream_wrapper *php_stream_locate_url_wrapper(const char >> *path, char **path_for_open, int options TSRMLS_DC) >> { >> HashTable *wrapper_hash = (FG(stream_wrappers) ? >> FG(stream_wrappers) : &url_stream_wrappers_hash); >> - php_stream_wrapper *wrapper = NULL; >> + php_stream_wrapper **wrapperpp = NULL; >> const char *p, *protocol = NULL; >> int n = 0; >> >> @@ -1529,7 +1530,7 @@ >> } >> >> if (protocol) { >> - if (FAILURE == zend_hash_find(wrapper_hash, (char*)protocol, >> n, (void**)&wrapper)) { >> + if (FAILURE == zend_hash_find(wrapper_hash, (char*)protocol, >> n, (void**)&wrapperpp)) { >> char wrapper_name[32]; >> >> if (n >= sizeof(wrapper_name)) >> @@ -1539,7 +1540,7 @@ >> php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unable to >> find the wrapper \"%s\" - did you forget to enable it when you >> configured PHP?", >> wrapper_name); >> >> - wrapper = NULL; >> + wrapperpp = NULL; >> protocol = NULL; >> } >> } >> @@ -1584,14 +1585,14 @@ >> if (FG(stream_wrappers)) { >> /* The file:// wrapper may have been disabled/overridden */ >> >> - if (wrapper) { >> + if (wrapperpp) { >> /* It was found so go ahead and provide it */ >> - return wrapper; >> + return *wrapperpp; >> } >> >> /* Check again, the original check might have not known >> the protocol name */ >> - if (zend_hash_find(wrapper_hash, "file", >> sizeof("file")-1, (void**)&wrapper) == SUCCESS) { >> - return wrapper; >> + if (zend_hash_find(wrapper_hash, "file", >> sizeof("file")-1, (void**)&wrapperpp) == SUCCESS) { >> + return *wrapperpp; >> } >> >> if (options & REPORT_ERRORS) { >> @@ -1604,14 +1605,14 @@ >> return &php_plain_files_wrapper; >> } >> >> - if (wrapper && wrapper->is_url && !PG(allow_url_fopen)) { >> + if (wrapperpp && (*wrapperpp)->is_url && !PG(allow_url_fopen)) { >> if (options & REPORT_ERRORS) { >> php_error_docref(NULL TSRMLS_CC, E_WARNING, "URL >> file-access is disabled in the server configuration"); >> } >> return NULL; >> } >> >> - return wrapper; >> + return *wrapperpp; >> } >> /* }}} */ >> >> http://cvs.php.net/viewcvs.cgi/php-src/main/streams/userspace.c?r1=1.31.2.2&r2=1.31.2.3&diff_format=u >> >> Index: php-src/main/streams/userspace.c >> diff -u php-src/main/streams/userspace.c:1.31.2.2 >> php-src/main/streams/userspace.c:1.31.2.3 >> --- php-src/main/streams/userspace.c:1.31.2.2 Sun Jan 1 12:50:18 2006 >> +++ php-src/main/streams/userspace.c Sat Apr 22 17:17:40 2006 >> @@ -17,7 +17,7 @@ >> >> +----------------------------------------------------------------------+ >> */ >> >> -/* $Id: userspace.c,v 1.31.2.2 2006/01/01 12:50:18 sniper Exp $ */ >> +/* $Id: userspace.c,v 1.31.2.3 2006/04/22 17:17:40 wez Exp $ */ >> >> #include "php.h" >> #include "php_globals.h" >> @@ -464,7 +464,7 @@ >> { >> char *protocol; >> int protocol_len; >> - php_stream_wrapper *wrapper = NULL; >> + php_stream_wrapper **wrapperpp = NULL, *wrapper; >> HashTable *global_wrapper_hash; >> >> if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", >> &protocol, &protocol_len) == FAILURE) { >> @@ -477,11 +477,14 @@ >> RETURN_TRUE; >> } >> >> - if ((zend_hash_find(global_wrapper_hash, protocol, protocol_len, >> (void**)&wrapper) == FAILURE) || !wrapper) { >> + if ((zend_hash_find(global_wrapper_hash, protocol, protocol_len, >> (void**)&wrapperpp) == FAILURE) || !wrapperpp) { >> php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s:// never >> existed, nothing to restore", protocol); >> RETURN_FALSE; >> } >> >> + /* next line might delete the pointer that wrapperpp points at, >> so deref it now */ >> + wrapper = *wrapperpp; >> + >> /* A failure here could be okay given that the protocol might >> have been merely unregistered */ >> php_unregister_url_stream_wrapper_volatile(protocol TSRMLS_CC); >> >> > > -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php