tony2001 Thu Jul 13 12:00:17 2006 UTC Added files: (Branch: PHP_5_2) /php-src/ext/standard/tests/file bug38086.phpt bug38086.txt stream_copy_to_stream.phpt
Modified files: /php-src NEWS /php-src/main/streams streams.c Log: MFH: fix #38086 (stream_copy_to_stream() returns 0 when maxlen is bigger than the actual length) add tests http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.119&r2=1.2027.2.547.2.120&diff_format=u Index: php-src/NEWS diff -u php-src/NEWS:1.2027.2.547.2.119 php-src/NEWS:1.2027.2.547.2.120 --- php-src/NEWS:1.2027.2.547.2.119 Wed Jul 12 09:51:47 2006 +++ php-src/NEWS Thu Jul 13 12:00:16 2006 @@ -82,6 +82,8 @@ - Fixed memory leaks in openssl streams context options. (Pierre) - Fixed handling of extremely long paths inside tempnam() function. (Ilia) +- Fixed bug #38086 (stream_copy_to_stream() returns 0 when maxlen is bigger + than the actual length). (Tony) - Fixed bug #38072 (boolean arg for mysqli_autocommit() is always true on Solaris). (Tony) - Fixed bug #38067 (Parameters are not decoded from utf-8 when using encoding http://cvs.php.net/viewvc.cgi/php-src/main/streams/streams.c?r1=1.82.2.6.2.3&r2=1.82.2.6.2.4&diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.82.2.6.2.3 php-src/main/streams/streams.c:1.82.2.6.2.4 --- php-src/main/streams/streams.c:1.82.2.6.2.3 Tue Jun 20 18:09:50 2006 +++ php-src/main/streams/streams.c Thu Jul 13 12:00:17 2006 @@ -19,7 +19,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: streams.c,v 1.82.2.6.2.3 2006/06/20 18:09:50 bjori Exp $ */ +/* $Id: streams.c,v 1.82.2.6.2.4 2006/07/13 12:00:17 tony2001 Exp $ */ #define _GNU_SOURCE #include "php.h" @@ -1348,11 +1348,7 @@ writeptr += didwrite; } } else { - if (maxlen == 0) { - return haveread; - } else { - return 0; /* error */ - } + return haveread; } if (maxlen - haveread == 0) { http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/bug38086.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/file/bug38086.phpt +++ php-src/ext/standard/tests/file/bug38086.phpt --TEST-- Bug #38086 (stream_copy_to_stream() returns 0 when maxlen is bigger than the actual length) --FILE-- <?php $initial_file = dirname(__FILE__).'/bug38086.txt'; $new_file = dirname(__FILE__).'/bug38086_1.txt'; $src = fopen($initial_file, 'r'); stream_filter_append($src, "string.rot13", STREAM_FILTER_READ); $dest = fopen($new_file, 'w'); var_dump(stream_copy_to_stream($src, $dest)); fclose($src); fclose($dest); var_dump(file_get_contents($new_file)); unlink($new_file); $src = fopen($initial_file, 'r'); stream_filter_append($src, "string.rot13", STREAM_FILTER_READ); $dest = fopen($new_file, 'w'); var_dump(stream_copy_to_stream($src, $dest, 10000)); fclose($src); fclose($dest); var_dump(file_get_contents($new_file)); unlink($new_file); echo "Done\n"; ?> --EXPECTF-- int(134) string(134) "Nabgure qnl Jura gur cnvaf bs yvsr jba'g one zl jnl V'yy oernx gurfr punvaf Gung ubyq zr qbja V'yy grne lbh qbja vagb zl cevingr uryy " int(134) string(134) "Nabgure qnl Jura gur cnvaf bs yvsr jba'g one zl jnl V'yy oernx gurfr punvaf Gung ubyq zr qbja V'yy grne lbh qbja vagb zl cevingr uryy " Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/bug38086.txt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/file/bug38086.txt +++ php-src/ext/standard/tests/file/bug38086.txt Another day When the pains of life won't bar my way I'll break these chains That hold me down I'll tear you down into my private hell http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/stream_copy_to_stream.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/file/stream_copy_to_stream.phpt +++ php-src/ext/standard/tests/file/stream_copy_to_stream.phpt --TEST-- stream_copy_to_stream() tests --FILE-- <?php $initial_file = dirname(__FILE__).'/bug38086.txt'; $new_file = dirname(__FILE__).'/bug38086_1.txt'; $src = fopen($initial_file, 'r'); stream_filter_append($src, "string.rot13", STREAM_FILTER_READ); $dest = fopen($new_file, 'w'); var_dump(stream_copy_to_stream($src, $dest, 0)); fclose($src); fclose($dest); var_dump(file_get_contents($new_file)); unlink($new_file); /* --- */ $src = fopen($initial_file, 'r'); stream_filter_append($src, "string.rot13", STREAM_FILTER_READ); $dest = fopen($new_file, 'w'); var_dump(stream_copy_to_stream($src, $dest, -1)); fclose($src); fclose($dest); var_dump(file_get_contents($new_file)); unlink($new_file); /* --- */ $src = fopen($initial_file, 'r'); stream_filter_append($src, "string.rot13", STREAM_FILTER_READ); $dest = fopen($new_file, 'w'); var_dump(stream_copy_to_stream($src, $dest)); fclose($src); fclose($dest); var_dump(file_get_contents($new_file)); unlink($new_file); /* --- */ $src = fopen($initial_file, 'r'); $dest = fopen($new_file, 'w'); var_dump(stream_copy_to_stream($src, $dest)); fclose($src); fclose($dest); var_dump(file_get_contents($new_file)); unlink($new_file); /* --- */ $src = fopen($initial_file, 'r'); $dest = fopen($new_file, 'w'); var_dump(stream_copy_to_stream($src, $dest, 1000000)); fclose($src); fclose($dest); var_dump(file_get_contents($new_file)); unlink($new_file); /* --- */ $src = fopen($initial_file, 'r'); $dest = fopen($new_file, 'w'); var_dump(stream_copy_to_stream($src, $dest, 10)); fclose($src); fclose($dest); var_dump(file_get_contents($new_file)); unlink($new_file); /* --- */ $src = fopen($initial_file, 'r'); $dest = fopen($new_file, 'w'); var_dump(stream_copy_to_stream($src, $dest, -1)); fclose($src); fclose($dest); var_dump(file_get_contents($new_file)); unlink($new_file); echo "Done\n"; ?> --EXPECTF-- int(0) string(0) "" int(134) string(134) "Nabgure qnl Jura gur cnvaf bs yvsr jba'g one zl jnl V'yy oernx gurfr punvaf Gung ubyq zr qbja V'yy grne lbh qbja vagb zl cevingr uryy " int(134) string(134) "Nabgure qnl Jura gur cnvaf bs yvsr jba'g one zl jnl V'yy oernx gurfr punvaf Gung ubyq zr qbja V'yy grne lbh qbja vagb zl cevingr uryy " int(134) string(134) "Another day When the pains of life won't bar my way I'll break these chains That hold me down I'll tear you down into my private hell " int(134) string(134) "Another day When the pains of life won't bar my way I'll break these chains That hold me down I'll tear you down into my private hell " int(10) string(10) "Another da" int(134) string(134) "Another day When the pains of life won't bar my way I'll break these chains That hold me down I'll tear you down into my private hell " Done -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php