summaryrefslogtreecommitdiff
path: root/main/streams.c
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2002-11-17 00:06:50 +0000
committerIlia Alshanetsky <iliaa@php.net>2002-11-17 00:06:50 +0000
commit3bef247fcc508245190eea3c45bc813f096beca0 (patch)
tree43e6b48d13b3ff5b5066a7f4a3136badf4be2ed9 /main/streams.c
parent2442adabe55e40ef7cf2033736607bf4ce0b3796 (diff)
downloadphp-git-3bef247fcc508245190eea3c45bc813f096beca0.tar.gz
Fixed a problem that would cause include/require("/dir/file") to fail on
Windows.
Diffstat (limited to 'main/streams.c')
-rwxr-xr-xmain/streams.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/main/streams.c b/main/streams.c
index f6190498c4..6d8d02d989 100755
--- a/main/streams.c
+++ b/main/streams.c
@@ -1579,6 +1579,32 @@ PHPAPI php_stream *_php_stream_fopen_with_path(char *filename, char *mode, char
return php_stream_fopen_rel(filename, mode, opened_path, options);
}
+
+#ifdef PHP_WIN32
+ if (IS_SLASH(filename[0])) {
+ int cwd_len;
+ char *cwd;
+ cwd = virtual_getcwd_ex(&cwd_len TSRMLS_CC);
+ /* getcwd() will return always return [DRIVE_LETTER]:/) on windows. */
+ *(cwd+3) = '\0';
+
+ snprintf(trypath, MAXPATHLEN, "%s%s", cwd, filename);
+
+ free(cwd);
+
+ if (php_check_open_basedir(trypath TSRMLS_CC)) {
+ return NULL;
+ }
+ if ((php_check_safe_mode_include_dir(trypath TSRMLS_CC)) == 0) {
+ return php_stream_fopen_rel(trypath, mode, opened_path, options);
+ }
+ if (PG(safe_mode) && (!php_checkuid(trypath, mode, CHECKUID_CHECK_MODE_PARAM))) {
+ return NULL;
+ }
+
+ return php_stream_fopen_rel(trypath, mode, opened_path, options);
+ }
+#endif
if (!path || (path && !*path)) {