diff options
author | Ilia Alshanetsky <iliaa@php.net> | 2009-10-14 01:32:07 +0000 |
---|---|---|
committer | Ilia Alshanetsky <iliaa@php.net> | 2009-10-14 01:32:07 +0000 |
commit | 31729738c78877069a4caba1450bb979256c8ff4 (patch) | |
tree | 6cc37e93beba3e7776660d28a0e79c8ba9831330 /ext/standard/exec.c | |
parent | 0e38a3d30362931a112b32da44237314971ae525 (diff) | |
download | php-git-31729738c78877069a4caba1450bb979256c8ff4.tar.gz |
Fixed bug #49847 (exec() fails to return data inside 2nd parameter, given output lines >4095 bytes).
Diffstat (limited to 'ext/standard/exec.c')
-rw-r--r-- | ext/standard/exec.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/ext/standard/exec.c b/ext/standard/exec.c index 65fe95115f..a460357ed2 100644 --- a/ext/standard/exec.c +++ b/ext/standard/exec.c @@ -62,7 +62,7 @@ PHPAPI int php_exec(int type, char *cmd, zval *array, zval *return_value TSRMLS_ { 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; @@ -157,13 +157,16 @@ PHPAPI int php_exec(int type, char *cmd, zval *array, zval *return_value TSRMLS_ } 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 */ |