From f56debe7d5703435e6a3cdd4c4c90b9de2527ae7 Mon Sep 17 00:00:00 2001 From: Mitch Jackson Date: Sun, 8 Jul 2018 23:15:20 -0500 Subject: RT# 80555 Sanitize leading 0's from ip addr input --- FS/FS/IP_Mixin.pm | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'FS/FS/IP_Mixin.pm') 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') ) { -- cgit v1.1