summaryrefslogtreecommitdiff
path: root/FS/FS/IP_Mixin.pm
diff options
context:
space:
mode:
authorMitch Jackson <mitch@freeside.biz>2018-07-08 23:15:20 -0500
committerMitch Jackson <mitch@freeside.biz>2018-10-19 19:42:15 -0400
commitf56debe7d5703435e6a3cdd4c4c90b9de2527ae7 (patch)
tree2cde3a8407ba859599da2e428afe0c93d9cc14cb /FS/FS/IP_Mixin.pm
parent966183ff11dd1a0b21eac2905118f478b84102c5 (diff)
RT# 80555 Sanitize leading 0's from ip addr input
Diffstat (limited to 'FS/FS/IP_Mixin.pm')
-rw-r--r--FS/FS/IP_Mixin.pm9
1 files changed, 9 insertions, 0 deletions
diff --git a/FS/FS/IP_Mixin.pm b/FS/FS/IP_Mixin.pm
index 3ec7693..0b138dd 100644
--- a/FS/FS/IP_Mixin.pm
+++ b/FS/FS/IP_Mixin.pm
@@ -94,6 +94,15 @@ sub ip_check {
$self->ip_addr('');
}
+ # strip user-entered leading 0's from IPv4 addresses
+ # Parsers like NetAddr::IP interpret them as octal instead of decimal
+ $self->ip_addr(
+ join( '.', (
+ map{ int($_) }
+ split( /\./, $self->ip_addr )
+ ))
+ ) if $self->ip_addr =~ /\./ && $self->ip_addr =~ /[\.^]0/;
+
if ( $self->ip_addr
and !$self->router
and $self->conf->exists('auto_router') ) {