Skip to content

Commit

Permalink
Fixing #5292 - is_resource_writeable() errors in Cacti log
Browse files Browse the repository at this point in the history
Also DNS check error checking.
  • Loading branch information
TheWitness committed Apr 7, 2023
1 parent 97fb42b commit 71ecf0f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -7244,7 +7244,11 @@ function char_to_dec($part) {
* @param mixed $type
*/
function cacti_gethostinfo($hostname, $type = DNS_ALL) {
return dns_get_record($hostname, $type);
if ($hostname != '') {
return dns_get_record($hostname, $type);
} else {
return false;
}
}

/**
Expand Down Expand Up @@ -7548,7 +7552,7 @@ function is_resource_writable(string $path) {
}

if (file_exists($path)) {
if (($f = @fopen($path, 'a'))) {
if (is_writable($path) && ($f = @fopen($path, 'a'))) {
fclose($f);

return true;
Expand All @@ -7557,7 +7561,7 @@ function is_resource_writable(string $path) {
return false;
}

if (($f = @fopen($path, 'w'))) {
if (is_writable($path) && ($f = @fopen($path, 'w'))) {
fclose($f);
unlink($path);

Expand Down

0 comments on commit 71ecf0f

Please sign in to comment.