com php-src: Fix Bug #66736 fpassthru broken: NEWS m ain/output.c main/streams/streams.c

From: Date: Thu, 03 Apr 2014 08:40:06 +0000
Subject: com php-src: Fix Bug #66736 fpassthru broken: NEWS m ain/output.c main/streams/streams.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-76697@lists.php.net to get a copy of this message
Commit: d08b4dbf23febd3f305a2682b03ab9c70f11ac60 Author: Michael Wallner <mike@php.net> Thu, 3 Apr 2014 10:40:06 +0200 Parents: 7ab5c593f77b229210a88d436270707f74b22b78 Branches: PHP-5.4 PHP-5.5 PHP-5.6 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=d08b4dbf23febd3f305a2682b03ab9c70f11ac60 Log: Fix Bug #66736 fpassthru broken Bugs: https://bugs.php.net/66736 Changed paths: M NEWS M main/output.c M main/streams/streams.c Diff: diff --git a/NEWS b/NEWS index bf3fa0c..7431228 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,7 @@ PHP NEWS . Fixed bug #64330 (stream_socket_server() creates wrong Abstract Namespace UNIX sockets). (Mike) . Fixed bug #66182 (exit in stream filter produces segfault). (Mike) + . Fixed bug #66736 (fpassthru broken). (Mike) - Embed: . Fixed bug #65715 (php5embed.lib isn't provided anymore). (Anatol) diff --git a/main/output.c b/main/output.c index 0777b64..e0d33d7 100644 --- a/main/output.c +++ b/main/output.c @@ -234,6 +234,13 @@ PHPAPI int php_output_get_status(TSRMLS_D) * Unbuffered write */ PHPAPI int php_output_write_unbuffered(const char *str, size_t len TSRMLS_DC) { +#if PHP_DEBUG + if (len > UINT_MAX) { + php_error(E_WARNING, "Attempt to output more than UINT_MAX bytes at once; " + "output will be truncated %lu => %lu", + (unsigned long) len, (unsigned long) (len % UINT_MAX)); + } +#endif if (OG(flags) & PHP_OUTPUT_DISABLED) { return 0; } @@ -248,6 +255,13 @@ PHPAPI int php_output_write_unbuffered(const char *str, size_t len TSRMLS_DC) * Buffered write */ PHPAPI int php_output_write(const char *str, size_t len TSRMLS_DC) { +#if PHP_DEBUG + if (len > UINT_MAX) { + php_error(E_WARNING, "Attempt to output more than UINT_MAX bytes at once; " + "output will be truncated %lu => %lu", + (unsigned long) len, (unsigned long) (len % UINT_MAX)); + } +#endif if (OG(flags) & PHP_OUTPUT_DISABLED) { return 0; } diff --git a/main/streams/streams.c b/main/streams/streams.c index acc67dc..1283377 100644 --- a/main/streams/streams.c +++ b/main/streams/streams.c @@ -1405,11 +1405,16 @@ PHPAPI size_t _php_stream_passthru(php_stream * stream STREAMS_DC TSRMLS_DC) p = php_stream_mmap_range(stream, php_stream_tell(stream), PHP_STREAM_MMAP_ALL, PHP_STREAM_MAP_MODE_SHARED_READONLY, &mapped); if (p) { - PHPWRITE(p, mapped); + do { + /* output functions return int, so pass in int max */ + if (0 < (b = PHPWRITE(p, MIN(mapped - bcount, INT_MAX)))) { + bcount += b; + } + } while (b > 0 && mapped > bcount); php_stream_mmap_unmap_ex(stream, mapped); - return mapped; + return bcount; } }

« previous php.cvs (#76697) next »