diff --git a/shadow.c b/shadow.c index cc3c896..b16dc04 100644 --- a/shadow.c +++ b/shadow.c @@ -591,16 +591,18 @@ static char *get_full_path(const char *filename TSRMLS_DC) static inline char *instance_to_template(const char *instname, int len TSRMLS_DC) { char *newname = NULL; - if (is_subdir_of(ZSTR_VAL(SHADOW_G(template)), ZSTR_LEN(SHADOW_G(template)), instname, len)) { - newname = estrndup(instname, len); - } else if (is_subdir_of(ZSTR_VAL(SHADOW_G(instance)), ZSTR_LEN(SHADOW_G(instance)), instname, len)) { - spprintf( - &newname, - MAXPATHLEN, - "%s/%s", - ZSTR_VAL(SHADOW_G(template)), - instname + ZSTR_LEN(SHADOW_G(instance)) + 1 - ); + if (SHADOW_ENABLED()) { + if (is_subdir_of(ZSTR_VAL(SHADOW_G(template)), ZSTR_LEN(SHADOW_G(template)), instname, len)) { + newname = estrndup(instname, len); + } else if (is_subdir_of(ZSTR_VAL(SHADOW_G(instance)), ZSTR_LEN(SHADOW_G(instance)), instname, len)) { + spprintf( + &newname, + MAXPATHLEN, + "%s/%s", + ZSTR_VAL(SHADOW_G(template)), + instname + ZSTR_LEN(SHADOW_G(instance)) + 1 + ); + } } return newname; } @@ -764,7 +766,7 @@ zend_string *shadow_resolve_path(const char *filename, int filename_len) result = original_zend_resolve_path(filename, filename_len); } if (SHADOW_G(debug) & SHADOW_DEBUG_RESOLVE) { - fprintf(stderr, "Resolve: %s -> %s\n", filename, ZSTR_VAL(result)); + fprintf(stderr, "Resolve: %s -> %s\n", filename, result ? ZSTR_VAL(result) : NULL); } return result; } diff --git a/tests/mkdir3.phpt b/tests/mkdir3.phpt new file mode 100644 index 0000000..159baf9 --- /dev/null +++ b/tests/mkdir3.phpt @@ -0,0 +1,17 @@ +--TEST-- +Check creating directories when shadow is not enabled +--SKIPIF-- + +--FILE-- + +--EXPECT-- +Created