From f6806ba64c33f51832299ab2e204d86aa58854a6 Mon Sep 17 00:00:00 2001 From: Peter Westwood Date: Sun, 13 Dec 2009 00:02:01 +0000 Subject: [PATCH] Fix the IP Address validation code in the FTP class. Fixes #11393 props nacin. git-svn-id: https://develop.svn.wordpress.org/trunk@12387 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/includes/class-ftp.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/wp-admin/includes/class-ftp.php b/wp-admin/includes/class-ftp.php index 0bf25e9c78..80703a9552 100644 --- a/wp-admin/includes/class-ftp.php +++ b/wp-admin/includes/class-ftp.php @@ -278,7 +278,10 @@ class ftp_base { $dns=@gethostbyaddr($host); if(!$ip) $ip=$host; if(!$dns) $dns=$host; - if(ip2long($ip) === -1) { + // Validate the IPAddress PHP4 returns -1 for invalid, PHP5 false + // -1 === "255.255.255.255" which is the broadcast address which is also going to be invalid + $ipaslong = ip2long($ip); + if ( ($ipaslong == false) || ($ipaslong === -1) ) { $this->SendMSG("Wrong host name/address \"".$host."\""); return FALSE; }