Skip to content

Commit 27542d9

Browse files
committed
Merge branch 'PHP-5.6' into PHP-7.0
* PHP-5.6: Accorate handling of too big inodes of chroot directories
2 parents 1d8be7c + 9849c97 commit 27542d9

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

ext/opcache/ZendAccelerator.c

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2091,18 +2091,16 @@ static void accel_activate(void)
20912091
if (stat("/", &buf) != 0) {
20922092
ZCG(root_hash) = 0;
20932093
} else {
2094-
zend_ulong x = buf.st_ino;
2095-
2096-
#if SIZEOF_ZEND_LONG == 4
2097-
x = ((x >> 16) ^ x) * 0x45d9f3b;
2098-
x = ((x >> 16) ^ x) * 0x45d9f3b;
2099-
x = (x >> 16) ^ x;
2100-
#elif SIZEOF_ZEND_LONG == 8
2101-
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
2102-
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
2103-
x = x ^ (x >> 31);
2104-
#endif
2105-
ZCG(root_hash) = x;
2094+
ZCG(root_hash) = buf.st_ino;
2095+
if (sizeof(buf.st_ino) > sizeof(ZCG(root_hash))) {
2096+
if (ZCG(root_hash) != buf.st_ino) {
2097+
zend_string *key = zend_string_init("opcache.enable", sizeof("opcache.enable")-1, 0);
2098+
zend_alter_ini_entry_chars(key, "0", 1, ZEND_INI_SYSTEM, ZEND_INI_STAGE_RUNTIME);
2099+
zend_string_release(key);
2100+
zend_accel_error(ACCEL_LOG_WARNING, "Can't cache files in chroot() directory with too big inode");
2101+
return;
2102+
}
2103+
}
21062104
}
21072105
} else {
21082106
ZCG(root_hash) = 0;

0 commit comments

Comments
 (0)