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 committed Nov 7, 2024
1 parent 38633fb commit fa79d54
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/SDK/Resource/Detectors/Host.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand All @@ -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');
Expand Down

0 comments on commit fa79d54

Please sign in to comment.