Skip to content

Commit

Permalink
Merge pull request #41539 from nextcloud/backport/37959/stable27
Browse files Browse the repository at this point in the history
[stable27] Check for open_basedir before reading /proc
  • Loading branch information
blizzz authored Nov 16, 2023
2 parents 4fe9738 + febc24d commit ec84b5c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/private/Preview/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,15 @@ public static function unguardWithSemaphore(false|\SysvSemaphore $semId): bool {
*/
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 (empty($openBasedir) || strpos($openBasedir, '/proc/cpuinfo') !== false) {
$width = is_readable('/proc/cpuinfo') ? substr_count(file_get_contents('/proc/cpuinfo'), 'processor') : 0;
} else {
$width = 0;
}
} else {
$width = 0;
}
Expand Down

0 comments on commit ec84b5c

Please sign in to comment.