From a76d529a5c4bc9724bfeadfc27a399b789880eea Mon Sep 17 00:00:00 2001 From: Ilia Rostovtsev Date: Sun, 28 Nov 2021 18:53:19 +0300 Subject: [PATCH] Fix IPv6 format for regex --- tcpwrappers/save_rule.cgi | 4 ++-- tcpwrappers/tcpwrappers-lib.pl | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tcpwrappers/save_rule.cgi b/tcpwrappers/save_rule.cgi index 2c0d7350e..f84094c16 100755 --- a/tcpwrappers/save_rule.cgi +++ b/tcpwrappers/save_rule.cgi @@ -24,9 +24,9 @@ if ($in{'delete'}) { &error($text{'save_eservice'}) if ($in{'service_except_custom'} && $in{'service_except_custom'} !~ /^[\w\d\s\-\/\.,]+$/); &error($text{'save_ehost'}) - if ($in{'host_text_def'} == 0 && $in{'host_text'} !~ /^[\w\d\s\-\/\@\.,]+$/ && $in{'host_text'} !~ /^\[[:\d]+\]/); + if ($in{'host_text_def'} == 0 && $in{'host_text'} !~ /^[\w\d\s\-\/\@\.,]+$/ && $in{'host_text'} !~ /^\[[:\da-f]+\]/); &error($text{'save_ehost'}) - if ($in{'host_except'} && $in{'host_except'} !~ /^[\w\d\s\-\/\@\.,]+$/ && $in{'host_except'} !~ /^\[[:\d]+\]/); + if ($in{'host_except'} && $in{'host_except'} !~ /^[\w\d\s\-\/\@\.,]+$/ && $in{'host_except'} !~ /^\[[:\da-f]+\]/); for (my $i = 0; $i <= $in{'cmd_count'}; $i++) { &error($text{'save_ecmd'}) if ($in{'cmd_'.$i} && $in{'cmd_'.$i} !~ /^[\w\d\s\-\/\@\%\|\(\)\'\"\&\.,]+$/); diff --git a/tcpwrappers/tcpwrappers-lib.pl b/tcpwrappers/tcpwrappers-lib.pl index d1bf9a1d9..df7dafa41 100755 --- a/tcpwrappers/tcpwrappers-lib.pl +++ b/tcpwrappers/tcpwrappers-lib.pl @@ -44,7 +44,7 @@ sub list_rules { my $ipv6_enc; # Match ipv6 with or without range - if ($line =~ /(?|(\[[:\d]+\]\/\d+)|(\[[:\d]+\]))/) { + if ($line =~ /(?|(\[[:\da-f]+\]\/\d+)|(\[[:\da-f]+\]))/) { $ipv6 = $1; $ipv6_enc = &encode_base64($ipv6); $line =~ s/\Q$ipv6\E/$ipv6_enc/;