[PHP-CVS] com php-src: Fixed Bug #61961 (file_get_content leaks when access empty file with max length): ext/standard/tests/file/bug61961.phpt main/streams/streams.c
Commit:3e9923dd8d08f88740f58e54386c0f7c569a5aa6 Author:Reeze Xia reeze@gmail.com Sun, 6 May 2012 18:27:26 +0800 Parents: 0956c00af999c295c5a13644ec835da8f96ad48d Branches: PHP-5.3 PHP-5.4 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=3e9923dd8d08f88740f58e54386c0f7c569a5aa6 Log: Fixed Bug #61961 (file_get_content leaks when access empty file with max length) Bugs: https://bugs.php.net/61961 Changed paths: A ext/standard/tests/file/bug61961.phpt M main/streams/streams.c Diff: diff --git a/ext/standard/tests/file/bug61961.phpt b/ext/standard/tests/file/bug61961.phpt new file mode 100644 index 000..ff0279a --- /dev/null +++ b/ext/standard/tests/file/bug61961.phpt @@ -0,0 +1,14 @@ +--TEST-- +Bug #61961 (file_get_content leaks when access empty file with max length) +--FILE-- +?php +$tmp_empty_file = __FILE__ . .tmp; +file_put_contents($tmp_empty_file, ); + +var_dump(file_get_contents($tmp_empty_file, NULL, NULL, NULL, 10)); +unlink($tmp_empty_file); +? +==DONE== +--EXPECT-- +string(0) +==DONE== \ No newline at end of file diff --git a/main/streams/streams.c b/main/streams/streams.c index 116c0aa..fe7800b 100755 --- a/main/streams/streams.c +++ b/main/streams/streams.c @@ -1366,7 +1366,12 @@ PHPAPI size_t _php_stream_copy_to_mem(php_stream *src, char **buf, size_t maxlen len += ret; ptr += ret; } - *ptr = '\0'; + if (len) { + *ptr = '\0'; + } else { + pefree(*buf, persistent); + *buf = NULL; + } return len; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Add NEWS entry for bug #61961: NEWS
Commit:304ac568c56799e60d90fadad3a936b61cab281b Author:Nikita Popov ni...@php.net Sun, 6 May 2012 13:19:17 +0200 Parents: 311ee8f69c9c91b78b35a787a5dbfdb34403753e Branches: PHP-5.3 PHP-5.4 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=304ac568c56799e60d90fadad3a936b61cab281b Log: Add NEWS entry for bug #61961 Bugs: https://bugs.php.net/61961 Changed paths: M NEWS Diff: diff --git a/NEWS b/NEWS index 5dee737..0d42b0f 100644 --- a/NEWS +++ b/NEWS @@ -34,6 +34,10 @@ PHP NEWS library. See https://bugs.gentoo.org/show_bug.cgi?id=364139 for detail. (Moriyoshi) +- Streams: + . Fixed bug #61961 (file_get_contents leaks when access empty file with +maxlen set). (Reeze) + (merge after 5.3.11 release) - Core: -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Merge branch 'PHP-5.4': main/streams/streams.c
Commit:9e1b690e0ce4b29416bd9f514a660d12e993aeab Author:Nikita Popov ni...@php.net Sun, 6 May 2012 13:40:06 +0200 Parents: 71e7c854b15db08c7bd9355791f859b5cea6e490 bef6111609bc05ae99f9392e507a47ae09ef72f9 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=9e1b690e0ce4b29416bd9f514a660d12e993aeab Log: Merge branch 'PHP-5.4' * PHP-5.4: Add NEWS entry for bug #61961 Fixed Bug #61961 (file_get_content leaks when access empty file with max length) Bugs: https://bugs.php.net/61961 Changed paths: MM main/streams/streams.c Diff: -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Merge branch 'PHP-5.3' into PHP-5.4: main/streams/streams.c
Commit:bef6111609bc05ae99f9392e507a47ae09ef72f9 Author:Nikita Popov ni...@php.net Sun, 6 May 2012 13:33:47 +0200 Parents: 0747b29bdf43be0682d10bdfc788f12f19ccf443 304ac568c56799e60d90fadad3a936b61cab281b Branches: PHP-5.4 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=bef6111609bc05ae99f9392e507a47ae09ef72f9 Log: Merge branch 'PHP-5.3' into PHP-5.4 * PHP-5.3: Add NEWS entry for bug #61961 Fixed Bug #61961 (file_get_content leaks when access empty file with max length) Bugs: https://bugs.php.net/61961 Changed paths: MM main/streams/streams.c Diff: -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Fixed bug #61730 (Segfault from array_walk modifying an array passed by reference): NEWS ext/standard/array.c ext/standard/tests/bug61730.phpt
Commit:7ccd5943924fd4ad9adcad1fbc547adc79114bff Author:Xinchen Hui larue...@php.net Sun, 6 May 2012 20:01:10 +0800 Parents: 304ac568c56799e60d90fadad3a936b61cab281b Branches: PHP-5.3 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=7ccd5943924fd4ad9adcad1fbc547adc79114bff Log: Fixed bug #61730 (Segfault from array_walk modifying an array passed by reference) Bugs: https://bugs.php.net/61730 Changed paths: M NEWS M ext/standard/array.c A ext/standard/tests/bug61730.phpt Diff: diff --git a/NEWS b/NEWS index 0d42b0f..c2b10e5 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,8 @@ PHP NEWS (Laruence) - Core: + . Fixed bug #61730 (Segfault from array_walk modifying an array passed by +reference). (Laruence) . Fixed missing bound check in iptcparse(). (chris at chiappa.net) . Fixed bug #61764 ('I' unpacks n as signed if n 2^31-1 on LP64). (Gustavo) . Fixed bug #54197 ([PATH=] sections incompatibility with user_ini.filename diff --git a/ext/standard/array.c b/ext/standard/array.c index 9956d00..e804ff8 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -1052,7 +1052,6 @@ static int php_array_walk(HashTable *target_hash, zval *userdata, int recursive char *string_key; uint string_key_len; ulong num_key; - HashPosition pos; /* Set up known arguments */ args[1] = key; @@ -1061,15 +1060,14 @@ static int php_array_walk(HashTable *target_hash, zval *userdata, int recursive Z_ADDREF_P(userdata); } - zend_hash_internal_pointer_reset_ex(target_hash, pos); - BG(array_walk_fci).retval_ptr_ptr = retval_ptr; BG(array_walk_fci).param_count = userdata ? 3 : 2; BG(array_walk_fci).params = args; BG(array_walk_fci).no_separation = 0; - + /* Iterate through hash */ - while (!EG(exception) zend_hash_get_current_data_ex(target_hash, (void **)args[0], pos) == SUCCESS) { + zend_hash_internal_pointer_reset(target_hash); + while (!EG(exception) zend_hash_get_current_data(target_hash, (void **)args[0]) == SUCCESS) { if (recursive Z_TYPE_PP(args[0]) == IS_ARRAY) { HashTable *thash; zend_fcall_info orig_array_walk_fci; @@ -1101,7 +1099,7 @@ static int php_array_walk(HashTable *target_hash, zval *userdata, int recursive MAKE_STD_ZVAL(key); /* Set up the key */ - switch (zend_hash_get_current_key_ex(target_hash, string_key, string_key_len, num_key, 0, pos)) { + switch (zend_hash_get_current_key_ex(target_hash, string_key, string_key_len, num_key, 0, NULL)) { case HASH_KEY_IS_LONG: Z_TYPE_P(key) = IS_LONG; Z_LVAL_P(key) = num_key; @@ -1129,7 +1127,7 @@ static int php_array_walk(HashTable *target_hash, zval *userdata, int recursive zval_ptr_dtor(key); key = NULL; } - zend_hash_move_forward_ex(target_hash, pos); + zend_hash_move_forward(target_hash); } if (userdata) { diff --git a/ext/standard/tests/bug61730.phpt b/ext/standard/tests/bug61730.phpt new file mode 100644 index 000..0fe9f22 --- /dev/null +++ b/ext/standard/tests/bug61730.phpt @@ -0,0 +1,37 @@ +--TEST-- +Bug #61730 (Segfault from array_walk modifying an array passed by reference) +--FILE-- +?php +$myArray = array_fill(0, 10, 1); + +array_walk( +$myArray, +function($value, $key) use ($myArray) +{ +reset($myArray); +} +); + +array_walk( +$myArray, +function($value, $key) use ($myArray) +{ +var_dump($key); +unset($myArray[$key]); +unset($myArray[$key+1]); +unset($myArray[$key+2]); +} +); + + + +print_r($myArray); +--EXPECT-- +int(0) +int(4) +int(8) +Array +( +[3] = 1 +[7] = 1 +) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Merge branch 'PHP-5.3' into PHP-5.4: NEWS ext/standard/array.c
Commit:4cceeb25b74eb89ff8d4106d1b195a1c18fc94d8 Author:Xinchen Hui larue...@php.net Sun, 6 May 2012 20:06:05 +0800 Parents: bef6111609bc05ae99f9392e507a47ae09ef72f9 7ccd5943924fd4ad9adcad1fbc547adc79114bff Branches: PHP-5.4 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=4cceeb25b74eb89ff8d4106d1b195a1c18fc94d8 Log: Merge branch 'PHP-5.3' into PHP-5.4 * PHP-5.3: Fixed bug #61730 (Segfault from array_walk modifying an array passed by reference) Bugs: https://bugs.php.net/61730 Changed paths: MM NEWS MM ext/standard/array.c Diff: diff --cc NEWS index 8b82237,c2b10e5..f88bf70 --- a/NEWS +++ b/NEWS @@@ -14,18 -11,10 +14,20 @@@ PH (Laruence) - Core: + . Fixed bug #61730 (Segfault from array_walk modifying an array passed by + reference). (Laruence) + . Fixed bug #61922 (ZTS build doesn't accept zend.script_encoding config). +(Laruence) . Fixed missing bound check in iptcparse(). (chris at chiappa.net) - . Fixed bug #61764 ('I' unpacks n as signed if n 2^31-1 on LP64). (Gustavo) + . Fixed bug #61827 (incorrect \e processing on Windows) (Anatoliy) + . Fixed bug #61761 ('Overriding' a private static method with a different +signature causes crash). (Laruence) + . Fixed bug #61728 (PHP crash when calling ob_start in request_shutdown +phase). (Laruence) + . Fixed bug #61660 (bin2hex(hex2bin($data)) != $data). (Nikita Popov) + . Fixed bug #61650 (ini parser crashes when using ${} ini variables +(without apache2)). (Laruence) + . Fixed bug #61605 (header_remove() does not remove all headers). (Laruence) . Fixed bug #54197 ([PATH=] sections incompatibility with user_ini.filename set to null). (Anatoliy) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Change the test folder: ext/standard/tests/array/bug61730.phpt ext/standard/tests/bug61730.phpt
Commit:99076bc24fae6b159c783e4772b0eaf046b5dc2e Author:Xinchen Hui larue...@php.net Sun, 6 May 2012 20:31:40 +0800 Parents: 7ccd5943924fd4ad9adcad1fbc547adc79114bff Branches: PHP-5.3 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=99076bc24fae6b159c783e4772b0eaf046b5dc2e Log: Change the test folder Changed paths: A ext/standard/tests/array/bug61730.phpt D ext/standard/tests/bug61730.phpt Diff: diff --git a/ext/standard/tests/array/bug61730.phpt b/ext/standard/tests/array/bug61730.phpt new file mode 100644 index 000..0fe9f22 --- /dev/null +++ b/ext/standard/tests/array/bug61730.phpt @@ -0,0 +1,37 @@ +--TEST-- +Bug #61730 (Segfault from array_walk modifying an array passed by reference) +--FILE-- +?php +$myArray = array_fill(0, 10, 1); + +array_walk( +$myArray, +function($value, $key) use ($myArray) +{ +reset($myArray); +} +); + +array_walk( +$myArray, +function($value, $key) use ($myArray) +{ +var_dump($key); +unset($myArray[$key]); +unset($myArray[$key+1]); +unset($myArray[$key+2]); +} +); + + + +print_r($myArray); +--EXPECT-- +int(0) +int(4) +int(8) +Array +( +[3] = 1 +[7] = 1 +) diff --git a/ext/standard/tests/bug61730.phpt b/ext/standard/tests/bug61730.phpt deleted file mode 100644 index 0fe9f22..000 --- a/ext/standard/tests/bug61730.phpt +++ /dev/null @@ -1,37 +0,0 @@ ---TEST-- -Bug #61730 (Segfault from array_walk modifying an array passed by reference) ---FILE-- -?php -$myArray = array_fill(0, 10, 1); - -array_walk( -$myArray, -function($value, $key) use ($myArray) -{ -reset($myArray); -} -); - -array_walk( -$myArray, -function($value, $key) use ($myArray) -{ -var_dump($key); -unset($myArray[$key]); -unset($myArray[$key+1]); -unset($myArray[$key+2]); -} -); - - - -print_r($myArray); ---EXPECT-- -int(0) -int(4) -int(8) -Array -( -[3] = 1 -[7] = 1 -) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: correct variable name: sapi/cli/php_cli_server.c
Commit:ad3a42c26c185d47aee8e69aad255c8824af4ded Author:Xinchen Hui larue...@php.net Sun, 6 May 2012 20:37:03 +0800 Parents: 376635cde8c4646caf8227c7f1d3e059d2817e6a Branches: PHP-5.4 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=ad3a42c26c185d47aee8e69aad255c8824af4ded Log: correct variable name Changed paths: M sapi/cli/php_cli_server.c Diff: diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c index a3ed390..0850425 100644 --- a/sapi/cli/php_cli_server.c +++ b/sapi/cli/php_cli_server.c @@ -1285,8 +1285,8 @@ static void php_cli_server_request_translate_vpath(php_cli_server_request *reque struct stat sb; static const char *index_files[] = { index.php, index.html, NULL }; char *buf = safe_pemalloc(1, request-vpath_len, 1 + document_root_len + 1 + sizeof(index.html), 1); - char *p = buf, *prev_patch = 0, *q, *vpath; - size_t prev_patch_len; + char *p = buf, *prev_path = NULL, *q, *vpath; + size_t prev_path_len; int is_static_file = 0; if (!buf) { @@ -1335,8 +1335,8 @@ static void php_cli_server_request_translate_vpath(php_cli_server_request *reque file++; } if (!*file || is_static_file) { - if (prev_patch) { - pefree(prev_patch, 1); + if (prev_path) { + pefree(prev_path, 1); } pefree(buf, 1); return; @@ -1344,25 +1344,25 @@ static void php_cli_server_request_translate_vpath(php_cli_server_request *reque } break; /* regular file */ } - if (prev_patch) { - pefree(prev_patch, 1); + if (prev_path) { + pefree(prev_path, 1); *q = DEFAULT_SLASH; } while (q buf *(--q) != DEFAULT_SLASH); - prev_patch_len = p - q; - prev_patch = pestrndup(q, prev_patch_len, 1); + prev_path_len = p - q; + prev_path = pestrndup(q, prev_path_len, 1); *q = '\0'; } - if (prev_patch) { - request-path_info_len = prev_patch_len; + if (prev_path) { + request-path_info_len = prev_path_len; #ifdef PHP_WIN32 - while (prev_patch_len--) { - if (prev_patch[prev_patch_len] == '\\') { - prev_patch[prev_patch_len] = '/'; + while (prev_pach_len--) { + if (prev_path[prev_path_len] == '\\') { + prev_path[prev_path_len] = '/'; } } #endif - request-path_info = prev_patch; + request-path_info = prev_path; pefree(request-vpath, 1); request-vpath = pestrndup(vpath, q - vpath, 1); request-vpath_len = q - vpath; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Fix bug 61769 Random failure of php_cli_server*phpt tests: sapi/cli/tests/php_cli_server.inc sapi/cli/tests/php_cli_server_014.phpt
Commit:87a011d3723aa9500e12a3f982df6b1f5cdfaedd Author:Matt Ficken mattfic...@php.net Sun, 6 May 2012 18:05:02 +0200 Committer: Anatoliy Belsky a...@php.net Sun, 6 May 2012 18:05:02 +0200 Parents: ad3a42c26c185d47aee8e69aad255c8824af4ded Branches: PHP-5.4 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=87a011d3723aa9500e12a3f982df6b1f5cdfaedd Log: Fix bug 61769 Random failure of php_cli_server*phpt tests Bugs: https://bugs.php.net/61769 Changed paths: M sapi/cli/tests/php_cli_server.inc M sapi/cli/tests/php_cli_server_014.phpt Diff: diff --git a/sapi/cli/tests/php_cli_server.inc b/sapi/cli/tests/php_cli_server.inc index 44ee76e..d24a679 100644 --- a/sapi/cli/tests/php_cli_server.inc +++ b/sapi/cli/tests/php_cli_server.inc @@ -1,5 +1,7 @@ ?php -define (PHP_CLI_SERVER_ADDRESS, localhost:8964); +define (PHP_CLI_SERVER_HOSTNAME, localhost); +define (PHP_CLI_SERVER_PORT, 8964); +define (PHP_CLI_SERVER_ADDRESS, PHP_CLI_SERVER_HOSTNAME.:.PHP_CLI_SERVER_PORT); function php_cli_server_start($code = 'echo Hello world;', $no_router = FALSE) { $php_executable = getenv('TEST_PHP_EXECUTABLE'); @@ -32,6 +34,19 @@ function php_cli_server_start($code = 'echo Hello world;', $no_router = FALSE) $handle = proc_open($cmd, $descriptorspec, $pipes, $doc_root); } + + // note: even when server prints 'Listening on localhost:8964...Press Ctrl-C to quit.' + // it might not be listening yet...need to wait until fsockopen() call returns + $fp = fsockopen(PHP_CLI_SERVER_HOSTNAME, PHP_CLI_SERVER_PORT); + if ($fp) { + // server will report Unexpected EOF error (socket opened, closed without writing + // anything) but that can be ignored + fclose($fp); + } else { + // test will fail to connect if server doesn't start listening/accepting + // in the next few microseconds + } + register_shutdown_function( function($handle) use($router) { @@ -40,7 +55,11 @@ function php_cli_server_start($code = 'echo Hello world;', $no_router = FALSE) }, $handle ); - usleep(5); + // don't bother sleeping, server is already up + //usleep(5); + // server can take a variable amount of time to be up, so just sleeping a guessed amount of time + // does not work. this is why tests sometimes pass and sometimes fail. to get a reliable pass + // sleeping doesn't work. } ? diff --git a/sapi/cli/tests/php_cli_server_014.phpt b/sapi/cli/tests/php_cli_server_014.phpt index 4b56caa..2eca870 100644 --- a/sapi/cli/tests/php_cli_server_014.phpt +++ b/sapi/cli/tests/php_cli_server_014.phpt @@ -13,6 +13,10 @@ list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS); $port = intval($port)?:80; $output = ''; +// note: select() on Windows ( some other platforms) has historical issues with +// timeouts less than 1000 millis(0.5). it may be better to increase these +// timeouts to 1000 millis(1.0) (fsockopen eventually calls select()). +// see articles like: http://support.microsoft.com/kb/257821 $fp = fsockopen($host, $port, $errno, $errstr, 0.5); if (!$fp) { die(connect failed); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php