From: Christoph M. Becker Date: Wed, 25 Mar 2020 21:49:57 +0000 (+0100) Subject: Fix php_exec() output length X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=556573b290ea5f47a156b432259fa29874390de8;p=php Fix php_exec() output length If trailing whitespace is stripped, we have to propagate the change of `bufl` back to php_exec(). --- diff --git a/ext/standard/exec.c b/ext/standard/exec.c index 61a63eaf75..b8b64b6aa2 100644 --- a/ext/standard/exec.c +++ b/ext/standard/exec.c @@ -91,7 +91,7 @@ static size_t strip_trailing_whitespace(char *buf, size_t bufl) { return bufl; } -static void handle_line(int type, zval *array, char *buf, size_t bufl) { +static size_t handle_line(int type, zval *array, char *buf, size_t bufl) { if (type == 1) { PHPWRITE(buf, bufl); if (php_output_get_level() < 1) { @@ -101,6 +101,7 @@ static void handle_line(int type, zval *array, char *buf, size_t bufl) { bufl = strip_trailing_whitespace(buf, bufl); add_next_index_stringl(array, buf, bufl); } + return bufl; } /* {{{ php_exec @@ -160,13 +161,13 @@ PHPAPI int php_exec(int type, char *cmd, zval *array, zval *return_value) bufl += b - buf; } - handle_line(type, array, buf, bufl); + bufl = handle_line(type, array, buf, bufl); b = buf; } if (bufl) { if (buf != b) { /* Process remaining output */ - handle_line(type, array, buf, bufl); + bufl = handle_line(type, array, buf, bufl); } /* Return last line from the shell command */