summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhil Davis <phil.davis@inf.org>2016-06-30 12:50:34 +0930
committerChris Buechler <cmb@pfsense.org>2016-06-30 00:00:42 -0500
commita77ed90de38d98d951ce7a468aa3af0be2ef0c88 (patch)
treee2462bf42494aa50b044d38982a9a1b0819b1794
parent75b8611e0572423691c8058ca036159a47dc6352 (diff)
downloadpfsense-a77ed90de38d98d951ce7a468aa3af0be2ef0c88.zip
pfsense-a77ed90de38d98d951ce7a468aa3af0be2ef0c88.tar.gz
Handle more invalid IPv6 formats
-rw-r--r--src/etc/inc/IPv6.inc18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/etc/inc/IPv6.inc b/src/etc/inc/IPv6.inc
index 815de65..d297ed1 100644
--- a/src/etc/inc/IPv6.inc
+++ b/src/etc/inc/IPv6.inc
@@ -557,7 +557,7 @@ class Net_IPv6
if (false !== strpos($uip, '::') ) {
- list($ip1, $ip2) = explode('::', $uip);
+ list($ip1, $ip2, $ip3) = explode('::', $uip);
if ("" == $ip1) {
@@ -606,21 +606,27 @@ class Net_IPv6
$uip = "0:0:0:0:0:0:0:0";
+ if (isset($ip3)) { // ::::xxx - not good
+ if ("" == $ip3) { // ::::
+ $ip3 = 0; // Give back a 9th "0"
+ }
+ $uip .= ":" . $ip3;
+ }
+
} else if (-1 == $c1) { // ::xxx
- $fill = str_repeat('0:', 7-$c2);
+ $fill = str_repeat('0:', max(1, 7-$c2));
$uip = str_replace('::', $fill, $uip);
} else if (-1 == $c2) { // xxx::
- $fill = str_repeat(':0', 7-$c1);
+ $fill = str_repeat(':0', max(1, 7-$c1));
$uip = str_replace('::', $fill, $uip);
} else { // xxx::xxx
- $fill = str_repeat(':0:', max(1, 6-$c2-$c1));
+ $fill = ':' . str_repeat('0:', max(1, 6-$c2-$c1));
$uip = str_replace('::', $fill, $uip);
- $uip = str_replace('::', ':', $uip);
}
}
@@ -921,7 +927,7 @@ class Net_IPv6
}
- if (8 == $count) {
+ if (8 == $count and empty($ipPart[1])) {
return true;
OpenPOWER on IntegriCloud