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:01:50 -0500
commitd0acb088cb5017c9daf5848049cec7f4b09a2a0d (patch)
treedaf646295c10c1bbdf24baf87f07c7deff97a14f
parentcd23382805ad27e0b90d51a555cc73565aaa5ccc (diff)
downloadpfsense-d0acb088cb5017c9daf5848049cec7f4b09a2a0d.zip
pfsense-d0acb088cb5017c9daf5848049cec7f4b09a2a0d.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