summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGit'Fellow <12234510+solracsf@users.noreply.github.com>2023-04-27 16:38:32 +0200
committerbackportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com>2023-11-16 12:59:55 +0000
commit4b97e1614bf3574e0252795da7d87e0759948cc9 (patch)
tree6a3358d218ce711fc76ec7946b8216fb0d47ea8e
parent8a7a89f42cc2a92c8041e83512eac1e25ef8ff55 (diff)
downloadnextcloud-server-4b97e1614bf3574e0252795da7d87e0759948cc9.tar.gz
nextcloud-server-4b97e1614bf3574e0252795da7d87e0759948cc9.zip
Check for open_basedir before reading /proc
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
-rw-r--r--lib/private/Preview/Generator.php16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/private/Preview/Generator.php b/lib/private/Preview/Generator.php
index c83cdb96e27..e88c307517d 100644
--- a/lib/private/Preview/Generator.php
+++ b/lib/private/Preview/Generator.php
@@ -264,8 +264,20 @@ class Generator {
public static function getHardwareConcurrency(): int {
static $width;
if (!isset($width)) {
- if (is_file("/proc/cpuinfo")) {
- $width = substr_count(file_get_contents("/proc/cpuinfo"), "processor");
+ if (function_exists('ini_get')) {
+ $openBasedir = ini_get('open_basedir');
+ if ($openBasedir == '') {
+ $width = is_readable('/proc/cpuinfo') ? substr_count(file_get_contents('/proc/cpuinfo'), 'processor') : 0;
+ } else {
+ $openBasedirPaths = explode(':', $openBasedir);
+ foreach ($openBasedirPaths as $path) {
+ if (strpos($path, '/proc') === 0 || $path === '/proc/cpuinfo') {
+ $width = is_readable('/proc/cpuinfo') ? substr_count(file_get_contents('/proc/cpuinfo'), 'processor') : 0;
+ } else {
+ $width = 0;
+ }
+ }
+ }
} else {
$width = 0;
}