[1/2] proxy.cgi: strip newline from subnet parameter

Message ID 20180211185122.9243-2-berny156@gmx.de
State Dropped
Headers
Series proxy.cgi fixes for bugzilla #10852 |

Commit Message

Bernhard Held Feb. 12, 2018, 5:51 a.m. UTC
  $temp[1] might end with a newline; this is unavoidable when specifying
serveral subnets. Thus, 'chomp $temp[1];' has to be moved before the
comparisons with the green and blue subnets. Otherwise the comparison
might always be true due to the newline.
---
 html/cgi-bin/proxy.cgi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Michael Tremer Feb. 12, 2018, 6:49 a.m. UTC | #1
This patch is fine.

On Sun, 2018-02-11 at 19:51 +0100, Bernhard Held wrote:
> $temp[1] might end with a newline; this is unavoidable when specifying
> serveral subnets. Thus, 'chomp $temp[1];' has to be moved before the
> comparisons with the green and blue subnets. Otherwise the comparison
> might always be true due to the newline.
> ---
>  html/cgi-bin/proxy.cgi | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/html/cgi-bin/proxy.cgi b/html/cgi-bin/proxy.cgi
> index 6aa14e15a..ea3b41126 100644
> --- a/html/cgi-bin/proxy.cgi
> +++ b/html/cgi-bin/proxy.cgi
> @@ -3064,12 +3064,12 @@ END
>  			foreach (@templist)
>  			{
>  				@temp = split(/\//);
> +				chomp $temp[1];
>  				if (
>  					($temp[0] ne $netsettings{'GREEN_NETADDRESS'}) && ($temp[1] ne $netsettings{'GREEN_NETMASK'}) &&
>  					($temp[0] ne $netsettings{'BLUE_NETADDRESS'}) && ($temp[1] ne $netsettings{'BLUE_NETMASK'})
>  					)
>  				{
> -					chomp $temp[1];
>  					print FILE " ||\n     (isInNet(myIpAddress(), \"$temp[0]\", \"$temp[1]\"))";
>  				}
>  			}
  

Patch

diff --git a/html/cgi-bin/proxy.cgi b/html/cgi-bin/proxy.cgi
index 6aa14e15a..ea3b41126 100644
--- a/html/cgi-bin/proxy.cgi
+++ b/html/cgi-bin/proxy.cgi
@@ -3064,12 +3064,12 @@  END
 			foreach (@templist)
 			{
 				@temp = split(/\//);
+				chomp $temp[1];
 				if (
 					($temp[0] ne $netsettings{'GREEN_NETADDRESS'}) && ($temp[1] ne $netsettings{'GREEN_NETMASK'}) &&
 					($temp[0] ne $netsettings{'BLUE_NETADDRESS'}) && ($temp[1] ne $netsettings{'BLUE_NETMASK'})
 					)
 				{
-					chomp $temp[1];
 					print FILE " ||\n     (isInNet(myIpAddress(), \"$temp[0]\", \"$temp[1]\"))";
 				}
 			}