summaryrefslogtreecommitdiffstats
path: root/src/etc/inc/IPv6.inc
diff options
context:
space:
mode:
authorPhil Davis <phil.davis@inf.org>2016-06-30 12:50:34 +0930
committerPhil Davis <phil.davis@inf.org>2016-06-30 12:50:34 +0930
commit7e9349a59c653668ab024d7e2e7f81667fb81cdb (patch)
tree468e2cf9c3d937e8ff5a716fa98a1e985a73b8aa /src/etc/inc/IPv6.inc
parent8d1a6065e111c1244dbc73471cbc7f23177a24eb (diff)
downloadpfsense-7e9349a59c653668ab024d7e2e7f81667fb81cdb.zip
pfsense-7e9349a59c653668ab024d7e2e7f81667fb81cdb.tar.gz
Handle more invalid IPv6 formats
Diffstat (limited to 'src/etc/inc/IPv6.inc')
-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