diff options
author | Chris Buechler <cmb@pfsense.org> | 2015-12-23 15:52:13 -0600 |
---|---|---|
committer | Chris Buechler <cmb@pfsense.org> | 2015-12-23 15:52:13 -0600 |
commit | f8a6c824dc576bcd0de777f45cd73f8b626d4197 (patch) | |
tree | aeb3c3aea7eaef78dd8eccc53f4e9683df30fbab /src/etc/inc/util.inc | |
parent | e6d22cd63fae76f9d9cc4607c03157bf9c603117 (diff) | |
download | pfsense-f8a6c824dc576bcd0de777f45cd73f8b626d4197.zip pfsense-f8a6c824dc576bcd0de777f45cd73f8b626d4197.tar.gz |
This broke things again. Revert "data sanitising: ip2long32, ip2ulong, long2ip32 (FIXED RESUBMIT of #2152)"
This reverts commit 4557e3fba627c91c37afba04681cdabf71eccf57.
Diffstat (limited to 'src/etc/inc/util.inc')
-rw-r--r-- | src/etc/inc/util.inc | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/src/etc/inc/util.inc b/src/etc/inc/util.inc index bd761d6..b542566 100644 --- a/src/etc/inc/util.inc +++ b/src/etc/inc/util.inc @@ -422,28 +422,21 @@ function gen_subnet_mask($bits) { } /* Convert long int to IPv4 address - Returns '' if not valid IPv4 (including if any bits >32 are non-zero) - NOTE: The test needs care, as several methods to test whether any high bits >= 33 are set, fails on x32 platforms. - The test uses ~0xFFFFFFFF which set all high bits >= 33 (if any) whatever the system INT size - Alternative test if ever needed that's known to work, is: (PHP_INT_SIZE <= 4 || ($ip >> 32) == 0)) - since if INT <4 bytes it's always ok and if not >>32 should be reliable. -*/ + Returns '' if not valid IPv4 (including if any bits >32 are non-zero) */ function long2ip32($ip) { - return ((is_int($ip) && ($ip & ~0xFFFFFFFF) == 0) ? long2ip($ip & 0xFFFFFFFF) : ''); - } + return long2ip($ip & 0xFFFFFFFF); +} /* Convert IPv4 address to long int, truncated to 32-bits to avoid sign extension on 64-bit platforms. Returns '' if not valid IPv4. */ function ip2long32($ip) { - $a = ip2long($ip); - return ($a === False ? '' : $a & 0xFFFFFFFF); + return (ip2long($ip) & 0xFFFFFFFF); } /* Convert IPv4 address to unsigned long int. Returns '' if not valid IPv4. */ function ip2ulong($ip) { - $a = ip2long($ip); - return ($a === False ? '' : sprintf("%u", $a & 0xFFFFFFFF)); + return sprintf("%u", ip2long32($ip)); } /* Find out how many IPs are contained within a given IP range |