summaryrefslogtreecommitdiff
path: root/ext/standard/exec.c
diff options
context:
space:
mode:
authorSean Bright <elixer@php.net>2001-04-28 13:16:18 +0000
committerSean Bright <elixer@php.net>2001-04-28 13:16:18 +0000
commit4175151567db7b29aa1fa67d842c6836d7696fda (patch)
treeaba65d4ea6420079d501a65e3eb8be6b90b25bad /ext/standard/exec.c
parent882751dd7dd77c1b826c4a4b3e0f151b136d7c68 (diff)
downloadphp-git-4175151567db7b29aa1fa67d842c6836d7696fda.tar.gz
- Fix for bugs #9042, #8212, and #8962. Patch from <tunacat@yahoo.com>
- Fixed proto for exec()
Diffstat (limited to 'ext/standard/exec.c')
-rw-r--r--ext/standard/exec.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/ext/standard/exec.c b/ext/standard/exec.c
index e0368e99c4..832251fbce 100644
--- a/ext/standard/exec.c
+++ b/ext/standard/exec.c
@@ -194,8 +194,10 @@ int php_Exec(int type, char *cmd, pval *array, pval *return_value)
/* strip trailing spaces */
l = strlen(buf);
t = l;
- while (l && isspace((int)buf[--l]));
- if (l < t) buf[l + 1] = '\0';
+ while (l && isspace((int)buf[l - 1])) {
+ l--;
+ }
+ if (l < t) buf[l] = '\0';
/* Return last line from the shell command */
if (PG(magic_quotes_runtime)) {
@@ -204,7 +206,7 @@ int php_Exec(int type, char *cmd, pval *array, pval *return_value)
tmp = php_addslashes(buf, 0, &len, 0);
RETVAL_STRINGL(tmp,len,0);
} else {
- RETVAL_STRINGL(buf,l?l+1:0,1);
+ RETVAL_STRINGL(buf,l,1);
}
} else {
int b, i;
@@ -233,7 +235,7 @@ int php_Exec(int type, char *cmd, pval *array, pval *return_value)
return FG(pclose_ret);
}
-/* {{{ proto int exec(string command [, array output [, int return_value]])
+/* {{{ proto string exec(string command [, array output [, int return_value]])
Execute an external program */
PHP_FUNCTION(exec)
{