From: Ilia Alshanetsky Date: Sun, 9 Dec 2007 16:37:02 +0000 (+0000) Subject: Fixed bug #43533 (escapeshellarg('') returns null). X-Git-Tag: php-5.2.6RC1~260 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2caccf3136dbe33292b16e1b7e7df8d90f5c4dd6;p=php Fixed bug #43533 (escapeshellarg('') returns null). # Backport of code from 5.3 --- diff --git a/NEWS b/NEWS index a9b9530cf0..6381f0b2a0 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,7 @@ PHP NEWS ?? ??? 2008, PHP 5.2.6 - Fixed weired behavior in CGI parameter parsing. (Dmitry, Hannes Magnusson) +- Fixed bug #43533 (escapeshellarg('') returns null). (Ilia) - Fixed bug #43495 (array_merge_recursive() crashes with recursive arrays). (Ilia) - Fixed bug #43493 (pdo_pgsql does not send username on connect when password diff --git a/ext/standard/exec.c b/ext/standard/exec.c index 71cc2ea899..fcab088433 100644 --- a/ext/standard/exec.c +++ b/ext/standard/exec.c @@ -392,18 +392,17 @@ PHP_FUNCTION(escapeshellcmd) Quote and escape an argument for use in a shell command */ PHP_FUNCTION(escapeshellarg) { - zval **arg1; + char *argument; + int argument_len; char *cmd = NULL; - if (zend_get_parameters_ex(1, &arg1) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &argument, &argument_len) == FAILURE) { + return; } - - convert_to_string_ex(arg1); - if (Z_STRLEN_PP(arg1)) { - cmd = php_escape_shell_arg(Z_STRVAL_PP(arg1)); - RETVAL_STRING(cmd, 1); - efree(cmd); + + if (argument) { + cmd = php_escape_shell_arg(argument); + RETVAL_STRING(cmd, 0); } } /* }}} */