From 9849c97b1bdfd7f0a7c499cad4cf601ebd68cc22 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Thu, 17 Nov 2016 01:08:42 +0300 Subject: [PATCH] Accorate handling of too big inodes of chroot directories --- ext/opcache/ZendAccelerator.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 9d0d32e8e4..7e8a444e7f 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -2155,18 +2155,14 @@ static void accel_activate(void) if (stat("/", &buf) != 0) { ZCG(root_hash) = 0; } else { - unsigned long x = buf.st_ino; - -#if SIZEOF_LONG == 4 - x = ((x >> 16) ^ x) * 0x45d9f3b; - x = ((x >> 16) ^ x) * 0x45d9f3b; - x = (x >> 16) ^ x; -#elif SIZEOF_LONG == 8 - x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; - x = (x ^ (x >> 27)) * 0x94d049bb133111eb; - x = x ^ (x >> 31); -#endif - ZCG(root_hash) = x; + ZCG(root_hash) = buf.st_ino; + if (sizeof(buf.st_ino) > sizeof(ZCG(root_hash))) { + if (ZCG(root_hash) != buf.st_ino) { + zend_alter_ini_entry("opcache.enable", sizeof("opcache.enable"), "0", 1, ZEND_INI_SYSTEM, ZEND_INI_STAGE_RUNTIME); + zend_accel_error(ACCEL_LOG_WARNING, "Can't cache files in chroot() directory with too big inode"); + return; + } + } } } else { ZCG(root_hash) = 0; -- 2.49.0