]> granicus.if.org Git - php/commitdiff
Fixed bug #49847 (exec() fails to return data inside 2nd parameter, given output...
authorIlia Alshanetsky <iliaa@php.net>
Wed, 14 Oct 2009 01:32:07 +0000 (01:32 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Wed, 14 Oct 2009 01:32:07 +0000 (01:32 +0000)
NEWS
ext/standard/exec.c

diff --git a/NEWS b/NEWS
index cb6e5e74706cb5803ecbc9c873dcfe1a43633a13..ae5b1d93ab37dcd466fe74c72cda7916054ebf72 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -19,6 +19,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 #49800 (SimpleXML allow (un)serialize() calls without warning).
   (Ilia, wmeler at wp-sa dot pl)
index 65fe95115f15be2ed3c1bb7f1fdf4baa425b1d81..a460357ed229b7209bc58c58ee8cedd0731ce8b6 100644 (file)
@@ -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 */