]> granicus.if.org Git - php/commitdiff
Fixed bug #70018 (exec does not strip all whitespace)
authorXinchen Hui <laruence@php.net>
Wed, 8 Jul 2015 11:30:37 +0000 (19:30 +0800)
committerXinchen Hui <laruence@php.net>
Wed, 8 Jul 2015 11:30:58 +0000 (19:30 +0800)
Merge branch 'PHP-5.6'

Conflicts:
ext/standard/exec.c

1  2 
NEWS
ext/standard/exec.c
ext/standard/tests/general_functions/bug70018.phpt

diff --cc NEWS
index 53828b0e817e8597f0452150d359012c06529adc,d4a456115058b82b55efb0d7c94ac9d9c40cc538..ceca8ad4c98dc7a0d097383ca4afc6d37e76e578
--- 1/NEWS
--- 2/NEWS
+++ b/NEWS
@@@ -5,24 -5,6 +5,27 @@@
  - Core:
    . Fixed bug #70012 (Exception lost with nested finally block). (Laruence)
  
++- Standard:
++  . Fixed bug #70018 (exec does not strip all whitespace). (Laruence)
++
 +09 Jul 2015, PHP 7.0.0 Beta 1
 +
 +- Core:
 +  . Fixed bug #70006 (cli - function with default arg = STDOUT crash output).
 +    (Laruence)
 +  . Fixed bug #69521 (Segfault in gc_collect_cycles()).
 +    (arjen at react dot com, Laruence)
 +  . Improved zend_string API (Francois Laupretre)
 +  . Fixed bug #69955 (Segfault when trying to combine [] and assign-op on
 +    ArrayAccess object). (Laruence)
 +  . Fixed bug #69957 (Different ways of handling div/mod/intdiv). (Bob)
 +  . Fixed bug #69900 (Too long timeout on pipes). (Anatol)
 +  . Fixed bug #62210 (Exceptions can leak temporary variables. As a part of
 +    the fix serious refactoring was done. op_array->brk_cont_array was removed,
 +    and replaced with more general and speed efficient op_array->T_liveliness.
 +    ZEND_GOTO opcode is always replaced by ZEND_JMP at compile time).
 +    (Bob, Dmitry, Laruence)
 +
  - CLI server:
    . Fixed bug #69655 (php -S changes MKCALENDAR request method to MKCOL). (cmb)
    . Fixed bug #64878 (304 responses return Content-Type header). (cmb)
index 55d777cb92d89f7beafdde21ac9223db3f0b5dc0,4764f4bf33a484a2520ca24e040693d0da0f5951..8dd0d5dfd742aa3fffdd8a22e8f3f5c11ef3f5c6
@@@ -116,8 -115,8 +116,8 @@@ PHPAPI int php_exec(int type, char *cmd
                        } else if (type == 2) {
                                /* strip trailing whitespaces */
                                l = bufl;
-                               while (l >= 1 && l-- && isspace(((unsigned char *)buf)[l]));
 -                              while (--l >= 0 && isspace(((unsigned char *)buf)[l]));
 -                              if (l != (int)(bufl - 1)) {
++                              while (l-- > 0 && isspace(((unsigned char *)buf)[l]));
 +                              if (l != (bufl - 1)) {
                                        bufl = l + 1;
                                        buf[bufl] = '\0';
                                }
                        /* strip trailing whitespaces if we have not done so already */
                        if ((type == 2 && buf != b) || type != 2) {
                                l = bufl;
-                               while (l >= 1 && l-- && isspace(((unsigned char *)buf)[l]));
 -                              while (--l >= 0 && isspace(((unsigned char *)buf)[l]));
 -                              if (l != (int)(bufl - 1)) {
++                              while (l-- > 0 && isspace(((unsigned char *)buf)[l]));
 +                              if (l != (bufl - 1)) {
                                        bufl = l + 1;
                                        buf[bufl] = '\0';
                                }
index 0000000000000000000000000000000000000000,0000000000000000000000000000000000000000..4862010a313cbed1b2fe966d25ba87383c8d161f
new file mode 100644 (file)
--- /dev/null
--- /dev/null
@@@ -1,0 -1,0 +1,15 @@@
++--TEST--
++Bug #70018 (exec does not strip all whitespace)
++--FILE--
++<?php
++$output = array();
++exec('/bin/echo -n -e "abc\f\n \n"',$output);
++var_dump($output);
++?>
++--EXPECT--
++array(2) {
++  [0]=>
++  string(3) "abc"
++  [1]=>
++  string(0) ""
++}