Skip to content

Commit 9849c97

Browse files
committed
Accorate handling of too big inodes of chroot directories
1 parent 935d922 commit 9849c97

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

ext/opcache/ZendAccelerator.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2155,18 +2155,14 @@ static void accel_activate(void)
21552155
if (stat("/", &buf) != 0) {
21562156
ZCG(root_hash) = 0;
21572157
} else {
2158-
unsigned long x = buf.st_ino;
2159-
2160-
#if SIZEOF_LONG == 4
2161-
x = ((x >> 16) ^ x) * 0x45d9f3b;
2162-
x = ((x >> 16) ^ x) * 0x45d9f3b;
2163-
x = (x >> 16) ^ x;
2164-
#elif SIZEOF_LONG == 8
2165-
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
2166-
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
2167-
x = x ^ (x >> 31);
2168-
#endif
2169-
ZCG(root_hash) = x;
2158+
ZCG(root_hash) = buf.st_ino;
2159+
if (sizeof(buf.st_ino) > sizeof(ZCG(root_hash))) {
2160+
if (ZCG(root_hash) != buf.st_ino) {
2161+
zend_alter_ini_entry("opcache.enable", sizeof("opcache.enable"), "0", 1, ZEND_INI_SYSTEM, ZEND_INI_STAGE_RUNTIME);
2162+
zend_accel_error(ACCEL_LOG_WARNING, "Can't cache files in chroot() directory with too big inode");
2163+
return;
2164+
}
2165+
}
21702166
}
21712167
} else {
21722168
ZCG(root_hash) = 0;

0 commit comments

Comments
 (0)