[prev in list] [next in list] [prev in thread] [next in thread]
List: pecl-cvs
Subject: [PECL-CVS] =?utf-8?q?svn:_/pecl/yaf/trunk/_package2.xml_tests/037.phpt_tests/060.phpt_yaf=5Floader.c
From: Xinchen_Hui <laruence () php ! net>
Date: 2012-11-21 7:58:03
Message-ID: svn-laruence-1353484683-328439-380773981 () svn ! php ! net
[Download RAW message or body]
laruence Wed, 21 Nov 2012 07:58:03 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=328439
Log:
Use VCWD_REALPATH instead of tricky implementation
Changed paths:
U pecl/yaf/trunk/package2.xml
U pecl/yaf/trunk/tests/037.phpt
U pecl/yaf/trunk/tests/060.phpt
U pecl/yaf/trunk/yaf_loader.c
Modified: pecl/yaf/trunk/package2.xml
===================================================================
--- pecl/yaf/trunk/package2.xml 2012-11-21 02:07:32 UTC (rev 328438)
+++ pecl/yaf/trunk/package2.xml 2012-11-21 07:58:03 UTC (rev 328439)
@@ -153,9 +153,7 @@
<file name="057.phpt" role="test" />
<file name="058.phpt" role="test" />
<file name="059.phpt" role="test" />
- <!--
<file name="060.phpt" role="test" />
- -->
<file name="061.phpt" role="test" />
<file name="062.phpt" role="test" />
<file name="build.inc" role="test" />
Modified: pecl/yaf/trunk/tests/037.phpt
===================================================================
--- pecl/yaf/trunk/tests/037.phpt 2012-11-21 02:07:32 UTC (rev 328438)
+++ pecl/yaf/trunk/tests/037.phpt 2012-11-21 07:58:03 UTC (rev 328439)
@@ -5,16 +5,11 @@
--INI--
open_basedir=.
yaf.lowcase_path=0
-yaf.library=/tmp/
--FILE--
<?php
$loader = Yaf_Loader::getInstance("/tmp");
-$loader->import("/tmp/1.php");
-$loader->autoload("Foo_Bar");
+$loader->import('/tmp/no_exists_037.php');
+$loader->autoload("Foo_Bar307");
?>
--EXPECTF--
-Warning: Yaf_Loader::import(): open_basedir restriction in effect. \
File(%stmp%c1.php) is not within the allowed path(s): (.) in \
%s037.php on line %d
-
-Warning: Yaf_Loader::autoload(): open_basedir restriction in effect. \
File(%stmp%cFoo%cBar.php) is not within the allowed path(s): (.) in %s037.php on line \
%d
-
-Warning: Yaf_Loader::autoload(): Failed opening script %stmp%cFoo%cBar.php: \
Operation not permitted in %s037.php on line %d +Warning: Yaf_Loader::autoload(): \
Failed opening script %sBar307.php: No such file or directory in %s037.php on line %d
Modified: pecl/yaf/trunk/tests/060.phpt
===================================================================
--- pecl/yaf/trunk/tests/060.phpt 2012-11-21 02:07:32 UTC (rev 328438)
+++ pecl/yaf/trunk/tests/060.phpt 2012-11-21 07:58:03 UTC (rev 328439)
@@ -5,8 +5,6 @@
--INI--
yaf.use_spl_autoload=1
yaf.lowcase_path=0
---XFAIL--
-We can not suppress EG(user_error_handler) for now
--FILE--
<?php
require "build.inc";
Modified: pecl/yaf/trunk/yaf_loader.c
===================================================================
--- pecl/yaf/trunk/yaf_loader.c 2012-11-21 02:07:32 UTC (rev 328438)
+++ pecl/yaf/trunk/yaf_loader.c 2012-11-21 07:58:03 UTC (rev 328439)
@@ -321,81 +321,24 @@
}
/* }}} */
-/** {{{ static void yaf_suppress_include_warning(int error_num, const char \
*error_filename, const uint error_lineno, const char *format, va_list \
args)
- */
-static void (*zend_origin_error_handler)(int error_num, const char *error_filename, \
const uint error_lineno, const char *format, va_list args);
-static void yaf_suppress_include_warning(int error_num, const char *error_filename, \
const uint error_lineno, const char *format, va_list args) {
- TSRMLS_FETCH();
- if (YAF_G(suppressing_warning) && error_num == E_WARNING) {
- char buffer[1024];
- int buffer_len;
- va_list copy;
-
-/* va_copy() is __va_copy() in old gcc versions.
- * According to the autoconf manual, using
- * memcpy(&dst, &src, sizeof(va_list))
- * gives maximum portability. */
-#ifndef va_copy
-# ifdef __va_copy
-# define va_copy(dest, src) __va_copy((dest), (src))
-# else
-# define va_copy(dest, src) memcpy(&(dest), &(src), sizeof(va_list))
-# endif
-#endif
- va_copy(copy, args);
-
- buffer_len = vsnprintf(buffer, sizeof(buffer), format, copy);
-#ifdef va_copy
- va_end(copy);
-#endif
-
- if (strstr(buffer, "failed to open stream: ") != NULL) {
- return;
- }
-
- if (strstr(buffer, "Failed opening ") != NULL) {
- return;
- }
- }
- return zend_origin_error_handler(error_num, error_filename, error_lineno, format, \
args);
-}
-/* }}} */
-
/** {{{ int yaf_loader_import(char *path, int len, int use_path TSRMLS_DC)
*/
int yaf_loader_import(char *path, int len, int use_path TSRMLS_DC) {
zend_file_handle file_handle;
zend_op_array *op_array;
- zend_bool restore_cb = 0;
+ char realpath[MAXPATHLEN];
+ if (!VCWD_REALPATH(path, realpath)) {
+ return 0;
+ }
+
file_handle.filename = path;
file_handle.free_filename = 0;
file_handle.type = ZEND_HANDLE_FILENAME;
file_handle.opened_path = NULL;
file_handle.handle.fp = NULL;
- /* we do such trick for performance issue */
- if (!zend_origin_error_handler) {
- restore_cb = 1;
- zend_origin_error_handler = zend_error_cb;
- zend_error_cb = yaf_suppress_include_warning;
- YAF_G(suppressing_warning) = 1;
- }
- zend_try {
- op_array = zend_compile_file(&file_handle, ZEND_INCLUDE TSRMLS_CC);
- } zend_catch {
- if (restore_cb) {
- YAF_G(suppressing_warning) = 0;
- zend_error_cb = zend_origin_error_handler;
- zend_origin_error_handler = NULL;
- }
- zend_bailout();
- } zend_end_try();
- if (restore_cb) {
- YAF_G(suppressing_warning) = 0;
- zend_error_cb = zend_origin_error_handler;
- zend_origin_error_handler = NULL;
- }
+ op_array = zend_compile_file(&file_handle, ZEND_INCLUDE TSRMLS_CC);
if (op_array && file_handle.handle.stream.handle) {
int dummy = 1;
--
PECL CVS Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic