]> granicus.if.org Git - php/commitdiff
Fixed invalid read
authorXinchen Hui <laruence@php.net>
Wed, 8 Jul 2015 11:06:49 +0000 (19:06 +0800)
committerXinchen Hui <laruence@php.net>
Wed, 8 Jul 2015 11:19:37 +0000 (19:19 +0800)
ext/standard/exec.c

index 66d4537dab13c2829e0bd668a697923aec582cac..4764f4bf33a484a2520ca24e040693d0da0f5951 100644 (file)
@@ -115,7 +115,7 @@ PHPAPI int php_exec(int type, char *cmd, zval *array, zval *return_value TSRMLS_
                        } else if (type == 2) {
                                /* strip trailing whitespaces */
                                l = bufl;
-                               while (l-- && isspace(((unsigned char *)buf)[l]));
+                               while (--l >= 0 && isspace(((unsigned char *)buf)[l]));
                                if (l != (int)(bufl - 1)) {
                                        bufl = l + 1;
                                        buf[bufl] = '\0';
@@ -128,7 +128,7 @@ PHPAPI int php_exec(int type, char *cmd, zval *array, zval *return_value TSRMLS_
                        /* strip trailing whitespaces if we have not done so already */
                        if ((type == 2 && buf != b) || type != 2) {
                                l = bufl;
-                               while (l-- && isspace(((unsigned char *)buf)[l]));
+                               while (--l >= 0 && isspace(((unsigned char *)buf)[l]));
                                if (l != (int)(bufl - 1)) {
                                        bufl = l + 1;
                                        buf[bufl] = '\0';