From: Andi Gutmans Date: Fri, 29 Oct 2004 00:37:51 +0000 (+0000) Subject: - [PATCH] Bug fix for #29770, but for PHP 4.3.9 (Vladimir Zidar) X-Git-Tag: php-5.0.3RC1~114 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8a340b1572d7b2a3709120e85a96f4ea08d5ac25;p=php - [PATCH] Bug fix for #29770, but for PHP 4.3.9 (Vladimir Zidar) --- diff --git a/ext/standard/file.c b/ext/standard/file.c index f7b2f6538f..171d24a3be 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -803,7 +803,7 @@ PHP_FUNCTION(popen) zval **arg1, **arg2; FILE *fp; char *p, *tmp = NULL; - char *b, buf[1024]; + char *b, *buf = 0; php_stream *stream; if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) { @@ -826,10 +826,11 @@ PHP_FUNCTION(popen) b = NULL; } } + if (b) { - snprintf(buf, sizeof(buf), "%s%s", PG(safe_mode_exec_dir), b); + spprintf(&buf, 0, "%s%s", PG(safe_mode_exec_dir), b); } else { - snprintf(buf, sizeof(buf), "%s/%s", PG(safe_mode_exec_dir), Z_STRVAL_PP(arg1)); + spprintf(&buf, 0, "%s/%s", PG(safe_mode_exec_dir), Z_STRVAL_PP(arg1)); } tmp = php_escape_shell_cmd(buf); @@ -839,8 +840,12 @@ PHP_FUNCTION(popen) if (!fp) { php_error_docref2(NULL TSRMLS_CC, buf, p, E_WARNING, "%s", strerror(errno)); efree(p); + efree(buf); RETURN_FALSE; } + + efree(buf); + } else { fp = VCWD_POPEN(Z_STRVAL_PP(arg1), p); if (!fp) {