pajoye                                   Thu, 15 Oct 2009 21:36:42 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=289688

Log:
- Merge: #49847

Bug: http://bugs.php.net/49847 (Closed) exec() confused by a specially crafted 
string
      
Changed paths:
    U   php/php-src/branches/PHP_5_3_1/ext/standard/exec.c

Modified: php/php-src/branches/PHP_5_3_1/ext/standard/exec.c
===================================================================
--- php/php-src/branches/PHP_5_3_1/ext/standard/exec.c  2009-10-15 21:32:24 UTC 
(rev 289687)
+++ php/php-src/branches/PHP_5_3_1/ext/standard/exec.c  2009-10-15 21:36:42 UTC 
(rev 289688)
@@ -62,7 +62,7 @@
 {
        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 @@
                }
                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 */

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to