version 1.1, 2012/02/21 23:48:02
|
version 1.1.1.3, 2013/07/22 01:32:05
|
Line 2
|
Line 2
|
+----------------------------------------------------------------------+ |
+----------------------------------------------------------------------+ |
| PHP Version 5 | |
| PHP Version 5 | |
+----------------------------------------------------------------------+ |
+----------------------------------------------------------------------+ |
| Copyright (c) 1997-2012 The PHP Group | | | Copyright (c) 1997-2013 The PHP Group | |
+----------------------------------------------------------------------+ |
+----------------------------------------------------------------------+ |
| This source file is subject to version 3.01 of the PHP license, | |
| This source file is subject to version 3.01 of the PHP license, | |
| that is bundled with this package in the file LICENSE, and is | |
| that is bundled with this package in the file LICENSE, and is | |
Line 47
|
Line 47
|
#include <errno.h> |
#include <errno.h> |
#include <ctype.h> |
#include <ctype.h> |
|
|
#include "safe_mode.h" |
|
#include "php_link.h" |
#include "php_link.h" |
#include "php_string.h" |
#include "php_string.h" |
|
|
Line 64 PHP_FUNCTION(readlink)
|
Line 63 PHP_FUNCTION(readlink)
|
return; |
return; |
} |
} |
|
|
if (strlen(link) != link_len) { |
|
RETURN_FALSE; |
|
} |
|
|
|
if (PG(safe_mode) && !php_checkuid(link, NULL, CHECKUID_CHECK_FILE_AND_DIR)) { |
|
RETURN_FALSE; |
|
} |
|
|
|
if (php_check_open_basedir(link TSRMLS_CC)) { |
if (php_check_open_basedir(link TSRMLS_CC)) { |
RETURN_FALSE; |
RETURN_FALSE; |
} |
} |
Line 94 PHP_FUNCTION(readlink)
|
Line 85 PHP_FUNCTION(readlink)
|
PHP_FUNCTION(linkinfo) |
PHP_FUNCTION(linkinfo) |
{ |
{ |
char *link; |
char *link; |
int link_len; | char *dirname; |
| int link_len, dir_len; |
struct stat sb; |
struct stat sb; |
int ret; |
int ret; |
|
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &link, &link_len) == FAILURE) { | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &link, &link_len) == FAILURE) { |
return; |
return; |
} |
} |
|
|
|
dirname = estrndup(link, link_len); |
|
dir_len = php_dirname(dirname, link_len); |
|
|
|
if (php_check_open_basedir(dirname TSRMLS_CC)) { |
|
efree(dirname); |
|
RETURN_FALSE; |
|
} |
|
|
ret = VCWD_LSTAT(link, &sb); |
ret = VCWD_LSTAT(link, &sb); |
if (ret == -1) { |
if (ret == -1) { |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", strerror(errno)); |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", strerror(errno)); |
|
efree(dirname); |
RETURN_LONG(-1L); |
RETURN_LONG(-1L); |
} |
} |
|
|
|
efree(dirname); |
RETURN_LONG((long) sb.st_dev); |
RETURN_LONG((long) sb.st_dev); |
} |
} |
/* }}} */ |
/* }}} */ |
Line 124 PHP_FUNCTION(symlink)
|
Line 126 PHP_FUNCTION(symlink)
|
char dirname[MAXPATHLEN]; |
char dirname[MAXPATHLEN]; |
size_t len; |
size_t len; |
|
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &topath, &topath_len, &frompath, &frompath_len) == FAILURE) { | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "pp", &topath, &topath_len, &frompath, &frompath_len) == FAILURE) { |
return; |
return; |
} |
} |
|
|
if (strlen(topath) != topath_len) { |
|
RETURN_FALSE; |
|
} |
|
|
|
if (strlen(frompath) != frompath_len) { |
|
RETURN_FALSE; |
|
} |
|
|
|
if (!expand_filepath(frompath, source_p TSRMLS_CC)) { |
if (!expand_filepath(frompath, source_p TSRMLS_CC)) { |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "No such file or directory"); |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "No such file or directory"); |
Line 156 PHP_FUNCTION(symlink)
|
Line 150 PHP_FUNCTION(symlink)
|
RETURN_FALSE; |
RETURN_FALSE; |
} |
} |
|
|
if (PG(safe_mode) && !php_checkuid(dest_p, NULL, CHECKUID_CHECK_FILE_AND_DIR)) { |
|
RETURN_FALSE; |
|
} |
|
|
|
if (PG(safe_mode) && !php_checkuid(source_p, NULL, CHECKUID_CHECK_FILE_AND_DIR)) { |
|
RETURN_FALSE; |
|
} |
|
|
|
if (php_check_open_basedir(dest_p TSRMLS_CC)) { |
if (php_check_open_basedir(dest_p TSRMLS_CC)) { |
RETURN_FALSE; |
RETURN_FALSE; |
} |
} |
Line 196 PHP_FUNCTION(link)
|
Line 182 PHP_FUNCTION(link)
|
char source_p[MAXPATHLEN]; |
char source_p[MAXPATHLEN]; |
char dest_p[MAXPATHLEN]; |
char dest_p[MAXPATHLEN]; |
|
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &topath, &topath_len, &frompath, &frompath_len) == FAILURE) { | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "pp", &topath, &topath_len, &frompath, &frompath_len) == FAILURE) { |
return; |
return; |
} |
} |
|
|
if (strlen(topath) != topath_len) { |
|
RETURN_FALSE; |
|
} |
|
|
|
if (strlen(frompath) != frompath_len) { |
|
RETURN_FALSE; |
|
} |
|
|
|
if (!expand_filepath(frompath, source_p TSRMLS_CC) || !expand_filepath(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"); |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "No such file or directory"); |
RETURN_FALSE; |
RETURN_FALSE; |
Line 217 PHP_FUNCTION(link)
|
Line 195 PHP_FUNCTION(link)
|
php_stream_locate_url_wrapper(dest_p, NULL, STREAM_LOCATE_WRAPPERS_ONLY TSRMLS_CC) ) |
php_stream_locate_url_wrapper(dest_p, NULL, STREAM_LOCATE_WRAPPERS_ONLY TSRMLS_CC) ) |
{ |
{ |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to link to a URL"); |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to link to a URL"); |
RETURN_FALSE; |
|
} |
|
|
|
if (PG(safe_mode) && !php_checkuid(dest_p, NULL, CHECKUID_CHECK_FILE_AND_DIR)) { |
|
RETURN_FALSE; |
|
} |
|
|
|
if (PG(safe_mode) && !php_checkuid(source_p, NULL, CHECKUID_CHECK_FILE_AND_DIR)) { |
|
RETURN_FALSE; |
RETURN_FALSE; |
} |
} |
|
|