summaryrefslogtreecommitdiff
path: root/main/user_streams.c
diff options
context:
space:
mode:
Diffstat (limited to 'main/user_streams.c')
-rw-r--r--main/user_streams.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/main/user_streams.c b/main/user_streams.c
index a6aff3cb8a..5c4ef63b92 100644
--- a/main/user_streams.c
+++ b/main/user_streams.c
@@ -21,6 +21,7 @@
#include "php.h"
#include "php_globals.h"
+#include "ext/standard/file.h"
static int le_protocols;
@@ -137,6 +138,13 @@ static php_stream *user_wrapper_opener(php_stream_wrapper *wrapper, char *filena
int call_result;
php_stream *stream = NULL;
+ /* Try to catch bad usage without prevent flexibility */
+ if (FG(user_stream_current_filename) != NULL && strcmp(filename, FG(user_stream_current_filename)) == 0) {
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "infinite recursion prevented");
+ return NULL;
+ }
+ FG(user_stream_current_filename) = filename;
+
us = emalloc(sizeof(*us));
us->wrapper = uwrap;
@@ -206,6 +214,8 @@ static php_stream *user_wrapper_opener(php_stream_wrapper *wrapper, char *filena
zval_ptr_dtor(&zmode);
zval_ptr_dtor(&zfilename);
+ FG(user_stream_current_filename) = NULL;
+
return stream;
}