summaryrefslogtreecommitdiff
path: root/main/fopen_wrappers.c
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@php.net>2008-08-04 07:20:15 +0000
committerDmitry Stogov <dmitry@php.net>2008-08-04 07:20:15 +0000
commit7355c3c54c1327ca496954622c0339fce3dc1835 (patch)
tree44c0afabf2d673036aba7a8529db7e8258c2d1a8 /main/fopen_wrappers.c
parent874b45607888dd5d208883e4f966ee365ff2b2ea (diff)
downloadphp-git-7355c3c54c1327ca496954622c0339fce3dc1835.tar.gz
Removed shebang line check from CGI sapi (it is checked by scanner)
Diffstat (limited to 'main/fopen_wrappers.c')
-rw-r--r--main/fopen_wrappers.c34
1 files changed, 11 insertions, 23 deletions
diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c
index 21a6a59950..fafe32315e 100644
--- a/main/fopen_wrappers.c
+++ b/main/fopen_wrappers.c
@@ -326,12 +326,9 @@ static FILE *php_fopen_and_set_opened_path(const char *path, const char *mode, c
*/
PHPAPI int php_fopen_primary_script(zend_file_handle *file_handle TSRMLS_DC)
{
- FILE *fp;
-#ifndef PHP_WIN32
- struct stat st;
-#endif
char *path_info, *filename;
int length;
+ zend_bool orig_display_errors;
filename = SG(request_info).path_translated;
path_info = SG(request_info).request_uri;
@@ -398,6 +395,8 @@ PHPAPI int php_fopen_primary_script(zend_file_handle *file_handle TSRMLS_DC)
}
} /* if doc_root && path_info */
+ filename = zend_resolve_path(filename, strlen(filename) TSRMLS_CC);
+
if (!filename) {
/* we have to free SG(request_info).path_translated here because
* php_destroy_request_info assumes that it will get
@@ -406,31 +405,20 @@ PHPAPI int php_fopen_primary_script(zend_file_handle *file_handle TSRMLS_DC)
STR_FREE(SG(request_info).path_translated);
SG(request_info).path_translated = NULL;
return FAILURE;
+ } else {
+ STR_FREE(SG(request_info).path_translated);
+ SG(request_info).path_translated = filename;
}
- fp = VCWD_FOPEN(filename, "rb");
-
-#ifndef PHP_WIN32
- /* refuse to open anything that is not a regular file */
- if (fp && (0 > fstat(fileno(fp), &st) || !S_ISREG(st.st_mode))) {
- fclose(fp);
- fp = NULL;
- }
-#endif
- if (!fp) {
+ orig_display_errors = PG(display_errors);
+ PG(display_errors) = 0;
+ if (zend_stream_open(filename, file_handle TSRMLS_CC) == FAILURE) {
+ PG(display_errors) = orig_display_errors;
STR_FREE(SG(request_info).path_translated); /* for same reason as above */
SG(request_info).path_translated = NULL;
return FAILURE;
}
-
- file_handle->opened_path = expand_filepath(filename, NULL TSRMLS_CC);
-
- SG(request_info).path_translated = filename;
-
- file_handle->filename = SG(request_info).path_translated;
- file_handle->free_filename = 0;
- file_handle->handle.fp = fp;
- file_handle->type = ZEND_HANDLE_FP;
+ PG(display_errors) = orig_display_errors;
return SUCCESS;
}