summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2020-09-17 07:36:47 +0300
committerAndrew Dolgov <[email protected]>2020-09-17 07:36:47 +0300
commit213d6330b1e3d26467647cc95d8a4f478b1ec796 (patch)
treebf335ac4b83309cddeb030ceffbd64e6116c8a6e /include
parent88c4dc405e04b219ed4ab76603f4cf82c073c140 (diff)
fetch_file_contents: resolve requested hosts and check for possible
loopback address
Diffstat (limited to 'include')
-rw-r--r--include/functions.php7
1 files changed, 7 insertions, 0 deletions
diff --git a/include/functions.php b/include/functions.php
index 508801fb7..4ef734218 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -243,6 +243,13 @@
if (!$url) return false;
$url_host = parse_url($url, PHP_URL_HOST);
+ $ip_addr = gethostbyname($url_host);
+
+ if (!$ip_addr || strpos($ip_addr, "127.0") === 0) {
+ $fetch_last_error = "URL hostname failed to resolve or resolved to loopback address ($ip_addr)";
+ return false;
+ }
+
$fetch_domain_hits[$url_host] += 1;
/*if ($fetch_domain_hits[$url_host] > MAX_FETCH_REQUESTS_PER_HOST) {