]> granicus.if.org Git - php/commitdiff
Merge branch 'PHP-5.6'
authorChristoph M. Becker <cmb@php.net>
Mon, 10 Aug 2015 23:42:25 +0000 (01:42 +0200)
committerChristoph M. Becker <cmb@php.net>
Mon, 10 Aug 2015 23:42:25 +0000 (01:42 +0200)
* PHP-5.6:
  Fix #69487: SAPI may truncate POST data

1  2 
main/SAPI.c

diff --cc main/SAPI.c
index f14638a22f1dc39a165be4ede5188eef2c601c94,9b5ea1ae622b679532ee65e5698257b1eacfbed3..1709ab10121c54937a4555c254bd1d3ac8838e02
@@@ -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))) {