Created
July 25, 2011 11:35
-
-
Save pierrejoye/1103956 to your computer and use it in GitHub Desktop.
do not resolve links on fopen&co only
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Index: main/fopen_wrappers.h | |
| =================================================================== | |
| --- main/fopen_wrappers.h (revision 313658) | |
| +++ main/fopen_wrappers.h (working copy) | |
| @@ -28,6 +28,7 @@ | |
| PHPAPI int php_fopen_primary_script(zend_file_handle *file_handle TSRMLS_DC); | |
| PHPAPI char *expand_filepath(const char *filepath, char *real_path TSRMLS_DC); | |
| PHPAPI char *expand_filepath_ex(const char *filepath, char *real_path, const char *relative_to, size_t relative_to_len TSRMLS_DC); | |
| +PHPAPI char *expand_filepath_use_realpath(const char *filepath, char *real_path, const char *relative_to, size_t relative_to_len, int use_realpath TSRMLS_DC); | |
| PHPAPI int php_check_open_basedir(const char *path TSRMLS_DC); | |
| PHPAPI int php_check_open_basedir_ex(const char *path, int warn TSRMLS_DC); | |
| Index: main/fopen_wrappers.c | |
| =================================================================== | |
| --- main/fopen_wrappers.c (revision 313658) | |
| +++ main/fopen_wrappers.c (working copy) | |
| @@ -741,6 +741,14 @@ | |
| */ | |
| PHPAPI char *expand_filepath_ex(const char *filepath, char *real_path, const char *relative_to, size_t relative_to_len TSRMLS_DC) | |
| { | |
| + return expand_filepath_use_realpath(filepath, real_path, relative_to, relative_to_len, CWD_FILEPATH TSRMLS_CC); | |
| +} | |
| +/* }}} */ | |
| + | |
| +/* {{{ expand_filepath_use_realpath | |
| + */ | |
| +PHPAPI char *expand_filepath_use_realpath(const char *filepath, char *real_path, const char *relative_to, size_t relative_to_len, int use_realpath TSRMLS_DC) | |
| +{ | |
| cwd_state new_state; | |
| char cwd[MAXPATHLEN]; | |
| int copy_len; | |
| @@ -785,7 +793,7 @@ | |
| new_state.cwd = strdup(cwd); | |
| new_state.cwd_length = strlen(cwd); | |
| - if (virtual_file_ex(&new_state, filepath, NULL, CWD_FILEPATH TSRMLS_CC)) { | |
| + if (virtual_file_ex(&new_state, filepath, NULL, use_realpath TSRMLS_CC)) { | |
| free(new_state.cwd); | |
| return NULL; | |
| } | |
| @@ -802,7 +810,6 @@ | |
| return real_path; | |
| } | |
| /* }}} */ | |
| - | |
| /* | |
| * Local variables: | |
| * tab-width: 4 | |
| Index: main/streams/plain_wrapper.c | |
| =================================================================== | |
| --- main/streams/plain_wrapper.c (revision 313658) | |
| +++ main/streams/plain_wrapper.c (working copy) | |
| @@ -909,9 +909,14 @@ | |
| if (options & STREAM_ASSUME_REALPATH) { | |
| realpath = estrdup(filename); | |
| } else { | |
| + | |
| + if ((realpath = expand_filepath_use_realpath(filename, NULL, NULL, 0, CWD_EXPAND TSRMLS_CC)) == NULL) { | |
| +#if 0 | |
| if ((realpath = expand_filepath(filename, NULL TSRMLS_CC)) == NULL) { | |
| +#endif | |
| return NULL; | |
| } | |
| + | |
| } | |
| if (persistent) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment