From ee299e2ecf6e9fbc6dbf7fdc18c5a8980e122b12 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Tue, 16 Jun 2015 11:33:43 +0200 Subject: [PATCH] connections.cgi: Fix broken NAT rules when there is an empty destination IP address MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Bug introduced with e60cd3a4042e95cf2748aac2de9d991c724ef24d Signed-off-by: Michael Tremer Reported-by: Daniel Weismüller --- html/cgi-bin/connections.cgi | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/html/cgi-bin/connections.cgi b/html/cgi-bin/connections.cgi index 5c17d33e27..4eb9cd7bfe 100644 --- a/html/cgi-bin/connections.cgi +++ b/html/cgi-bin/connections.cgi @@ -540,7 +540,7 @@ foreach my $line (@conntrack) { $ttl = format_time($ttl); my $sip_extra; - if ($sip ne $sip_ret) { + if ($sip_ret && $sip ne $sip_ret) { $sip_extra = "> "; $sip_extra .= ""; $sip_extra .= " $sip_ret"; @@ -548,7 +548,7 @@ foreach my $line (@conntrack) { } my $dip_extra; - if ($dip ne $dip_ret) { + if ($dip_ret && $dip ne $dip_ret) { $dip_extra = "> "; $dip_extra .= ""; $dip_extra .= " $dip_ret"; @@ -661,15 +661,17 @@ sub ipcolour($) { my ($ip) = $_[0]; my $found = 0; - foreach my $line (@network) { - if ($network[$id] eq '') { - $id++; - } else { - if (!$found && ipv4_in_network($network[$id], $masklen[$id], $ip) ) { - $found = 1; - $colour = $colour[$id]; + if ($ip) { + foreach my $line (@network) { + if ($network[$id] eq '') { + $id++; + } else { + if (!$found && ipv4_in_network($network[$id], $masklen[$id], $ip) ) { + $found = 1; + $colour = $colour[$id]; + } + $id++; } - $id++; } } -- 2.39.2