From fa79d54945e13e1679c1726f33598bdd75dbe013 Mon Sep 17 00:00:00 2001 From: John Date: Thu, 7 Nov 2024 13:07:25 -0800 Subject: [PATCH] guard against possible false value from file_get_contents in Host.php --- src/SDK/Resource/Detectors/Host.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/SDK/Resource/Detectors/Host.php b/src/SDK/Resource/Detectors/Host.php index 7d74f6991..1763dc18e 100644 --- a/src/SDK/Resource/Detectors/Host.php +++ b/src/SDK/Resource/Detectors/Host.php @@ -54,7 +54,8 @@ private function getLinuxId(): ?string foreach ($paths as $path) { $file = $this->dir . $path; if (is_file($file) && is_readable($file)) { - return trim(file_get_contents($file)); + $contents = file_get_contents($file); + return $contents !== false ? trim($contents) : null; } } @@ -65,7 +66,8 @@ private function getBsdId(): ?string { $file = $this->dir . self::PATH_ETC_HOSTID; if (is_file($file) && is_readable($file)) { - return trim(file_get_contents($file)); + $contents = file_get_contents($file); + return $contents !== false ? trim($contents) : null; } $out = exec('which kenv && kenv -q smbios.system.uuid');