Skip to content

Commit

Permalink
guard against possible false value from file_get_contents in Host.php (
Browse files Browse the repository at this point in the history
  • Loading branch information
jspaetzel authored Nov 15, 2024
1 parent 38633fb commit 7b5cbb5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/SDK/Resource/Detectors/Host.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ 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;
}
}

Expand All @@ -65,7 +67,9 @@ 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');
Expand Down

0 comments on commit 7b5cbb5

Please sign in to comment.