]> 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 4e569842e346efaf0c7265242d27d086b9043a05..e5f8f80f95496f9bb5293bbf66d8eedd5c88e9ac 100644 (file)
--- 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)
index e0843718306af14a603e067f26e35919f7b569f7..5af2d9c679545fca8a8f9f716f4a3c79ae84923f 100644 (file)
@@ -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 */