summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/standard/file.c11
-rw-r--r--ext/standard/link.c50
-rw-r--r--ext/standard/tests/file/fgetc_variation2.phpt13
-rw-r--r--ext/standard/tests/file/readlink_realpath_error.phpt8
-rw-r--r--ext/standard/tests/file/symlink_link_linkinfo_is_link_error1.phpt10
-rw-r--r--ext/standard/tests/file/symlink_link_linkinfo_is_link_error2.phpt6
6 files changed, 41 insertions, 57 deletions
diff --git a/ext/standard/file.c b/ext/standard/file.c
index 4e7ddc1848..d2874d8cbb 100644
--- a/ext/standard/file.c
+++ b/ext/standard/file.c
@@ -2358,16 +2358,15 @@ out:
Return the resolved path */
PHP_FUNCTION(realpath)
{
- zval **path;
+ char *filename;
+ int filename_len;
char resolved_path_buff[MAXPATHLEN];
- if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(ZEND_NUM_ARGS(), &path) == FAILURE) {
- WRONG_PARAM_COUNT;
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) {
+ return;
}
- convert_to_string_ex(path);
-
- if (VCWD_REALPATH(Z_STRVAL_PP(path), resolved_path_buff)) {
+ if (VCWD_REALPATH(filename, resolved_path_buff)) {
if (PG(safe_mode) && (!php_checkuid(resolved_path_buff, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
RETURN_FALSE;
}
diff --git a/ext/standard/link.c b/ext/standard/link.c
index ebda3100a4..9b54018db0 100644
--- a/ext/standard/link.c
+++ b/ext/standard/link.c
@@ -54,24 +54,24 @@
Return the target of a symbolic link */
PHP_FUNCTION(readlink)
{
- zval **filename;
+ char *link;
+ int link_len;
char buff[MAXPATHLEN];
int ret;
- if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &filename) == FAILURE) {
- WRONG_PARAM_COUNT;
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &link, &link_len) == FAILURE) {
+ return;
}
- convert_to_string_ex(filename);
- if (PG(safe_mode) && !php_checkuid(Z_STRVAL_PP(filename), NULL, CHECKUID_CHECK_FILE_AND_DIR)) {
+ if (PG(safe_mode) && !php_checkuid(link, NULL, CHECKUID_CHECK_FILE_AND_DIR)) {
RETURN_FALSE;
}
- if (php_check_open_basedir(Z_STRVAL_PP(filename) TSRMLS_CC)) {
+ if (php_check_open_basedir(link TSRMLS_CC)) {
RETURN_FALSE;
}
- ret = readlink(Z_STRVAL_PP(filename), buff, MAXPATHLEN-1);
+ ret = readlink(link, buff, MAXPATHLEN-1);
if (ret == -1) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", strerror(errno));
@@ -88,16 +88,16 @@ PHP_FUNCTION(readlink)
Returns the st_dev field of the UNIX C stat structure describing the link */
PHP_FUNCTION(linkinfo)
{
- zval **filename;
+ char *link;
+ int link_len;
struct stat sb;
int ret;
- if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &filename) == FAILURE) {
- WRONG_PARAM_COUNT;
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &link, &link_len) == FAILURE) {
+ return;
}
- convert_to_string_ex(filename);
- ret = VCWD_LSTAT(Z_STRVAL_PP(filename), &sb);
+ ret = VCWD_LSTAT(link, &sb);
if (ret == -1) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", strerror(errno));
RETURN_LONG(-1L);
@@ -111,18 +111,17 @@ PHP_FUNCTION(linkinfo)
Create a symbolic link */
PHP_FUNCTION(symlink)
{
- zval **topath, **frompath;
+ char *topath, *frompath;
+ int topath_len, frompath_len;
int ret;
char source_p[MAXPATHLEN];
char dest_p[MAXPATHLEN];
- if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &topath, &frompath) == FAILURE) {
- WRONG_PARAM_COUNT;
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &topath, &topath_len, &frompath, &frompath_len) == FAILURE) {
+ return;
}
- convert_to_string_ex(topath);
- convert_to_string_ex(frompath);
- if (!expand_filepath(Z_STRVAL_PP(frompath), source_p TSRMLS_CC) || !expand_filepath(Z_STRVAL_PP(topath), dest_p TSRMLS_CC)) {
+ if (!expand_filepath(frompath, source_p TSRMLS_CC) || !expand_filepath(topath, dest_p TSRMLS_CC)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "No such file or directory");
RETURN_FALSE;
}
@@ -151,7 +150,7 @@ PHP_FUNCTION(symlink)
}
#ifndef ZTS
- ret = symlink(Z_STRVAL_PP(topath), Z_STRVAL_PP(frompath));
+ ret = symlink(topath, frompath);
#else
ret = symlink(dest_p, source_p);
#endif
@@ -168,18 +167,17 @@ PHP_FUNCTION(symlink)
Create a hard link */
PHP_FUNCTION(link)
{
- zval **topath, **frompath;
+ char *topath, *frompath;
+ int topath_len, frompath_len;
int ret;
char source_p[MAXPATHLEN];
char dest_p[MAXPATHLEN];
- if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &topath, &frompath) == FAILURE) {
- WRONG_PARAM_COUNT;
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &topath, &topath_len, &frompath, &frompath_len) == FAILURE) {
+ return;
}
- convert_to_string_ex(topath);
- convert_to_string_ex(frompath);
- if (!expand_filepath(Z_STRVAL_PP(frompath), source_p TSRMLS_CC) || !expand_filepath(Z_STRVAL_PP(topath), dest_p TSRMLS_CC)) {
+ if (!expand_filepath(frompath, source_p TSRMLS_CC) || !expand_filepath(topath, dest_p TSRMLS_CC)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "No such file or directory");
RETURN_FALSE;
}
@@ -208,7 +206,7 @@ PHP_FUNCTION(link)
}
#ifndef ZTS
- ret = link(Z_STRVAL_PP(topath), Z_STRVAL_PP(frompath));
+ ret = link(topath, frompath);
#else
ret = link(dest_p, source_p);
#endif
diff --git a/ext/standard/tests/file/fgetc_variation2.phpt b/ext/standard/tests/file/fgetc_variation2.phpt
index d733c29092..75ac3488b4 100644
--- a/ext/standard/tests/file/fgetc_variation2.phpt
+++ b/ext/standard/tests/file/fgetc_variation2.phpt
@@ -50,16 +50,3 @@ Notice: Undefined variable: file_handle in %s on line %d
Warning: fgetc(): supplied argument is not a valid stream resource in %s on line %d
bool(false)
Done
---UEXPECTF--
-*** Testing fgetc() : usage variations ***
--- Testing fgetc() with closed handle --
-
-Warning: fgetc(): 6 is not a valid stream resource in %s on line %d
-bool(false)
--- Testing fgetc() with unset handle --
-
-Notice: Undefined variable: file_handle in %s on line %d
-
-Warning: fgetc(): supplied argument is not a valid stream resource in %s on line %d
-bool(false)
-Done
diff --git a/ext/standard/tests/file/readlink_realpath_error.phpt b/ext/standard/tests/file/readlink_realpath_error.phpt
index f568601a9f..dc042bfff5 100644
--- a/ext/standard/tests/file/readlink_realpath_error.phpt
+++ b/ext/standard/tests/file/readlink_realpath_error.phpt
@@ -40,10 +40,10 @@ echo "Done\n";
--EXPECTF--
*** Testing readlink(): error conditions ***
-Warning: Wrong parameter count for readlink() in %s on line %d
+Warning: readlink() expects exactly 1 parameter, 0 given in %s on line %d
NULL
-Warning: Wrong parameter count for readlink() in %s on line %d
+Warning: readlink() expects exactly 1 parameter, 2 given in %s on line %d
NULL
*** Testing readlink() on a non-existent link ***
@@ -62,10 +62,10 @@ Warning: readlink(): Invalid argument in %s on line %d
bool(false)
*** Testing realpath(): error conditions ***
-Warning: Wrong parameter count for realpath() in %s on line %d
+Warning: realpath() expects exactly 1 parameter, 0 given in %s on line %d
NULL
-Warning: Wrong parameter count for realpath() in %s on line %d
+Warning: realpath() expects exactly 1 parameter, 2 given in %s on line %d
NULL
*** Testing realpath() on a non-existent file ***
diff --git a/ext/standard/tests/file/symlink_link_linkinfo_is_link_error1.phpt b/ext/standard/tests/file/symlink_link_linkinfo_is_link_error1.phpt
index 2d393b2e4d..8aae9b3bca 100644
--- a/ext/standard/tests/file/symlink_link_linkinfo_is_link_error1.phpt
+++ b/ext/standard/tests/file/symlink_link_linkinfo_is_link_error1.phpt
@@ -6,7 +6,7 @@ if (substr(PHP_OS, 0, 3) == 'WIN') {
die('skip no symlinks on Windows');
}
if (substr(PHP_OS, 0, 3) == 'SUN') {
- die('skip Not valid for Sun Solaris');
+ die('skip Not valid for Sun Solaris');
}
if (PHP_INT_SIZE != 4) {
die("skip this test is for 32bit platform only");
@@ -72,10 +72,10 @@ unlink(dirname(__FILE__)."/symlink_link_linkinfo_is_link_error1.tmp");
--EXPECTF--
*** Testing symlink() for error conditions ***
-Warning: Wrong parameter count for symlink() in %s on line %d
+Warning: symlink() expects exactly 2 parameters, 0 given in %s on line %d
NULL
-Warning: Wrong parameter count for symlink() in %s on line %d
+Warning: symlink() expects exactly 2 parameters, 3 given in %s on line %d
NULL
Warning: symlink(): %s in %s on line %d
@@ -98,10 +98,10 @@ bool(false)
*** Testing linkinfo() for error conditions ***
-Warning: Wrong parameter count for linkinfo() in %s on line %d
+Warning: linkinfo() expects exactly 1 parameter, 0 given in %s on line %d
NULL
-Warning: Wrong parameter count for linkinfo() in %s on line %d
+Warning: linkinfo() expects exactly 1 parameter, 2 given in %s on line %d
NULL
Warning: linkinfo(): %s in %s on line %d
diff --git a/ext/standard/tests/file/symlink_link_linkinfo_is_link_error2.phpt b/ext/standard/tests/file/symlink_link_linkinfo_is_link_error2.phpt
index b8b233ab60..3bee688d87 100644
--- a/ext/standard/tests/file/symlink_link_linkinfo_is_link_error2.phpt
+++ b/ext/standard/tests/file/symlink_link_linkinfo_is_link_error2.phpt
@@ -5,7 +5,7 @@ Test symlink(), linkinfo(), link() and is_link() functions : error conditions -
if (substr(PHP_OS, 0, 3) == 'WIN') {
die('skip no symlinks on Windows');
}
-if (PHP_INT_SIZE != 4) {
+if (PHP_INT_SIZE != 4 ) {
die("skip this test is for 32bit platform only");
}
?>
@@ -69,10 +69,10 @@ unlink(dirname(__FILE__)."/symlink_link_linkinfo_is_link_error2.tmp");
--EXPECTF--
*** Testing link() for error conditions ***
-Warning: Wrong parameter count for link() in %s on line %d
+Warning: link() expects exactly 2 parameters, 0 given in %s on line %d
NULL
-Warning: Wrong parameter count for link() in %s on line %d
+Warning: link() expects exactly 2 parameters, 3 given in %s on line %d
NULL
Warning: link(): %s in %s on line %d