From: Christoph M. Becker Date: Mon, 10 Aug 2015 23:42:25 +0000 (+0200) Subject: Merge branch 'PHP-5.6' X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=37707b2dd663f5bb9b344ff9aa604002035be842;p=php Merge branch 'PHP-5.6' * PHP-5.6: Fix #69487: SAPI may truncate POST data --- 37707b2dd663f5bb9b344ff9aa604002035be842 diff --cc main/SAPI.c index f14638a22f,9b5ea1ae62..1709ab1012 --- a/main/SAPI.c +++ b/main/SAPI.c @@@ -282,10 -287,15 +282,15 @@@ SAPI_API SAPI_POST_READER_FUNC(sapi_rea for (;;) { char buffer[SAPI_POST_BLOCK_SIZE]; - read_bytes = sapi_read_post_block(buffer, SAPI_POST_BLOCK_SIZE TSRMLS_CC); + read_bytes = sapi_read_post_block(buffer, SAPI_POST_BLOCK_SIZE); if (read_bytes > 0) { - php_stream_write(SG(request_info).request_body, buffer, read_bytes); + if (php_stream_write(SG(request_info).request_body, buffer, read_bytes) != read_bytes) { + /* if parts of the stream can't be written, purge it completely */ + php_stream_truncate_set_size(SG(request_info).request_body, 0); - php_error_docref(NULL TSRMLS_CC, E_WARNING, "POST data can't be buffered; all data discarded"); ++ php_error_docref(NULL, E_WARNING, "POST data can't be buffered; all data discarded"); + break; + } } if ((SG(post_max_size) > 0) && (SG(read_post_bytes) > SG(post_max_size))) {