Skip to content

Commit 96d5d7c

Browse files
committed
Merge branch 'master' of https://git.php.net/push/php-src
2 parents 91aa9fb + 882862e commit 96d5d7c

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

ext/standard/user_filters.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,11 @@ php_stream_filter_status_t userfilter_filter(
180180
zval zpropname;
181181
int call_result;
182182

183+
/* the userfilter object probably doesn't exist anymore */
184+
if (CG(unclean_shutdown)) {
185+
return ret;
186+
}
187+
183188
if (FAILURE == zend_hash_find(Z_OBJPROP_P(obj), "stream", sizeof("stream"), (void**)&zstream)) {
184189
/* Give the userfilter class a hook back to the stream */
185190
ALLOC_INIT_ZVAL(zstream);

main/output.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,13 @@ PHPAPI int php_output_get_status(TSRMLS_D)
234234
* Unbuffered write */
235235
PHPAPI int php_output_write_unbuffered(const char *str, size_t len TSRMLS_DC)
236236
{
237+
#if PHP_DEBUG
238+
if (len > UINT_MAX) {
239+
php_error(E_WARNING, "Attempt to output more than UINT_MAX bytes at once; "
240+
"output will be truncated %lu => %lu",
241+
(unsigned long) len, (unsigned long) (len % UINT_MAX));
242+
}
243+
#endif
237244
if (OG(flags) & PHP_OUTPUT_DISABLED) {
238245
return 0;
239246
}
@@ -248,6 +255,13 @@ PHPAPI int php_output_write_unbuffered(const char *str, size_t len TSRMLS_DC)
248255
* Buffered write */
249256
PHPAPI int php_output_write(const char *str, size_t len TSRMLS_DC)
250257
{
258+
#if PHP_DEBUG
259+
if (len > UINT_MAX) {
260+
php_error(E_WARNING, "Attempt to output more than UINT_MAX bytes at once; "
261+
"output will be truncated %lu => %lu",
262+
(unsigned long) len, (unsigned long) (len % UINT_MAX));
263+
}
264+
#endif
251265
if (OG(flags) & PHP_OUTPUT_DISABLED) {
252266
return 0;
253267
}

main/streams/streams.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,11 +1400,16 @@ PHPAPI size_t _php_stream_passthru(php_stream * stream STREAMS_DC TSRMLS_DC)
14001400
p = php_stream_mmap_range(stream, php_stream_tell(stream), PHP_STREAM_MMAP_ALL, PHP_STREAM_MAP_MODE_SHARED_READONLY, &mapped);
14011401

14021402
if (p) {
1403-
PHPWRITE(p, mapped);
1403+
do {
1404+
/* output functions return int, so pass in int max */
1405+
if (0 < (b = PHPWRITE(p, MIN(mapped - bcount, INT_MAX)))) {
1406+
bcount += b;
1407+
}
1408+
} while (b > 0 && mapped > bcount);
14041409

14051410
php_stream_mmap_unmap_ex(stream, mapped);
14061411

1407-
return mapped;
1412+
return bcount;
14081413
}
14091414
}
14101415

0 commit comments

Comments
 (0)