From 1bc451744f91d0a80cfa27989ab9bd4684650aab Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Wed, 14 Oct 2009 01:32:07 +0000 Subject: [PATCH] Fixed bug #49847 (exec() fails to return data inside 2nd parameter, given output lines >4095 bytes). --- NEWS | 2 ++ ext/standard/exec.c | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 4e569842e3..e5f8f80f95 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,8 @@ PHP NEWS - Fixed crash when instantiating PDORow and PDOStatement through Reflection. (Felipe) +- Fixed bug #49847 (exec() fails to return data inside 2nd parameter, given + output lines >4095 bytes). (Ilia) - Fixed bug #49809 (time_sleep_until() is not available on OpenSolaris). (Jani) - Fixed Bug #49785 (insufficient input string validation of htmlspecialchars()). (Moriyoshi, hello at iwamot dot com) diff --git a/ext/standard/exec.c b/ext/standard/exec.c index e084371830..5af2d9c679 100644 --- a/ext/standard/exec.c +++ b/ext/standard/exec.c @@ -62,7 +62,7 @@ int php_exec(int type, char *cmd, zval *array, zval *return_value TSRMLS_DC) { FILE *fp; char *buf, *tmp=NULL; - int l, pclose_return; + int l = 0, pclose_return; char *cmd_p, *b, *c, *d=NULL; php_stream *stream; size_t buflen, bufl = 0; @@ -154,13 +154,16 @@ int php_exec(int type, char *cmd, zval *array, zval *return_value TSRMLS_DC) } if (bufl) { /* strip trailing whitespaces if we have not done so already */ - if (type != 2) { + if ((type == 2 && bufl && !l) || type != 2) { l = bufl; while (l-- && isspace(((unsigned char *)buf)[l])); if (l != (int)(bufl - 1)) { bufl = l + 1; buf[bufl] = '\0'; } + if (type == 2) { + add_next_index_stringl(array, buf, bufl, 1); + } } /* Return last line from the shell command */ -- 2.50.1