From 0f892c9ffc3b6e7976fe5cfb1f175eb564f0c1bc Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 7 Apr 2020 12:30:51 +0200 Subject: [PATCH] Check for existance and readability of static leases file before trying to access it. Signed-off-by: DL6ER --- scripts/pi-hole/php/savesettings.php | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/scripts/pi-hole/php/savesettings.php b/scripts/pi-hole/php/savesettings.php index 6c8b1e89..611cd587 100644 --- a/scripts/pi-hole/php/savesettings.php +++ b/scripts/pi-hole/php/savesettings.php @@ -79,16 +79,10 @@ function readStaticLeasesFile($origin_file="/etc/dnsmasq.d/04-pihole-static-dhcp { global $dhcp_static_leases; $dhcp_static_leases = array(); - try - { - $dhcpstatic = @fopen($origin_file, 'r'); - } - catch(Exception $e) - { - echo "Warning: Failed to read ".$origin_file.", this is not an error"; + if(!file_exists($origin_file) || !is_readable($origin_file)) return false; - } - + + $dhcpstatic = @fopen($origin_file, 'r'); if(!is_resource($dhcpstatic)) return false;