diff options
author | Ermal <eri@pfsense.org> | 2011-05-25 15:38:54 +0000 |
---|---|---|
committer | Ermal <eri@pfsense.org> | 2011-05-25 15:38:54 +0000 |
commit | c749ef62ec8ecb3d7f38f7de49e5029631614ef5 (patch) | |
tree | 2dd888f6a9f27d6619e9f7b5e3aa8e8b9dc4c017 | |
parent | f0e80b72a3c359f52596e9b6948178ad48d6bb1b (diff) | |
download | pfsense-c749ef62ec8ecb3d7f38f7de49e5029631614ef5.zip pfsense-c749ef62ec8ecb3d7f38f7de49e5029631614ef5.tar.gz |
Check that the returned ip is an ip_address and not blindly trust the returned information.
-rw-r--r-- | etc/inc/dyndns.class | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/etc/inc/dyndns.class b/etc/inc/dyndns.class index 150dedc..8f9a695 100644 --- a/etc/inc/dyndns.class +++ b/etc/inc/dyndns.class @@ -795,13 +795,15 @@ if($successful_update == true) { /* Write WAN IP to cache file */ $wan_ip = $this->_checkIP(); - $currentTime = time(); - log_error("phpDynDNS: updating cache file {$this->_cacheFile}: {$wan_ip}"); - conf_mount_rw(); - $file = fopen($this->_cacheFile, 'w'); - fwrite($file, $wan_ip.':'.$currentTime); - fclose($file); - conf_mount_ro(); + if (is_ipaddr($wan_ip)) { + $currentTime = time(); + log_error("phpDynDNS: updating cache file {$this->_cacheFile}: {$wan_ip}"); + conf_mount_rw(); + $file = fopen($this->_cacheFile, 'w'); + fwrite($file, $wan_ip.':'.$currentTime); + fclose($file); + conf_mount_ro(); + } } $this->status = $status; log_error($status); @@ -957,7 +959,12 @@ $ip_result_decoded = urldecode($ip_result_page); preg_match('/Current IP Address: (.*)<\/body>/', $ip_result_decoded, $matches); $ip_address = trim($matches[1]); - log_error("DynDns debug information: {$ip_address} extracted from {$hosttocheck}"); + if (is_ipaddr($ip_address)) + log_error("DynDns debug information: {$ip_address} extracted from {$hosttocheck}"); + else { + log_error("DynDns debug information: IP address could not be extracted from {$hosttocheck}"); + return 0; + } } else log_error("DynDns debug information: {$ip_address} extracted from local system."); |