Skip to content

Commit 781e863

Browse files
committed
fix: hardening for opcache.enable_file_override
If the PHP instance has aggressive caching enabled, with `opcache.enable_file_override` and sufficiently long or disabled `opcache.validate_timestamps`, `file_exists($versionFileName)` can retrun true after the file was removed from disk. `require_once $versionFileName;` however requires the file to exist on disk, even if it has an OPcache entry. With this commit, the cache entry is invalidated before `file_exists($versionFileName)` is called, to harden the updater for instances with `opcache.enable_file_override`. Signed-off-by: MichaIng <micha@dietpi.com>
1 parent 7d8b694 commit 781e863

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

index.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ public function __construct(
8282
}
8383

8484
$versionFileName = $this->nextcloudDir . '/version.php';
85+
// Invalidate version.php OPcache entry to assure file_exists() returns
86+
// false after files were removed while opcache.enable_file_override is set.
87+
if (function_exists('opcache_invalidate')) {
88+
opcache_invalidate($versionFileName, true);
89+
}
8590
if (!file_exists($versionFileName)) {
8691
// fallback to version in config.php
8792
$version = $this->getConfigOptionString('version');

0 commit comments

Comments
 (0)