Skip to content

Commit

Permalink
Merge pull request #34 from alex-vlasov/BR-5458
Browse files Browse the repository at this point in the history
BR-5458: Shadow crash with PHP 7.1 in healthcheck
  • Loading branch information
yellowandy authored Jul 31, 2017
2 parents 49575e7 + ed6b2f8 commit 795c16c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 11 deletions.
24 changes: 13 additions & 11 deletions shadow.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
17 changes: 17 additions & 0 deletions tests/mkdir3.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--TEST--
Check creating directories when shadow is not enabled
--SKIPIF--
<?php if (!extension_loaded('shadow')) {
print 'skip';
} ?>
--FILE--
<?php
$instance = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'instance';
mkdir("$instance/cache/upgrades");

echo "Created\n";

rmdir("$instance/cache/upgrades");
?>
--EXPECT--
Created

0 comments on commit 795c16c

Please sign in to comment.