diff options
author | Michael Wallner <mike@php.net> | 2014-04-03 10:41:24 +0200 |
---|---|---|
committer | Michael Wallner <mike@php.net> | 2014-04-03 10:41:24 +0200 |
commit | 55005c86383f4616a2ca02333af9630f617a1a2e (patch) | |
tree | 6c9dfa69ce9c6c025cb0c0d18cee3d0b294f1b27 | |
parent | 1c2bcec68a260502b72bda9eb8a1e9c3ef4ddafe (diff) | |
parent | 60ef357ffcc0335ff728cef498bfc9e06773fd3a (diff) | |
download | php-git-55005c86383f4616a2ca02333af9630f617a1a2e.tar.gz |
Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5:
NEWS
Fix Bug #66736 fpassthru broken
-rw-r--r-- | main/output.c | 14 | ||||
-rw-r--r-- | main/streams/streams.c | 9 |
2 files changed, 21 insertions, 2 deletions
diff --git a/main/output.c b/main/output.c index 72092e9561..1dac7179b8 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 5049d88df6..9f9661dbfd 100644 --- a/main/streams/streams.c +++ b/main/streams/streams.c @@ -1400,11 +1400,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; } } |