Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 17 May 2017 17:49:34 -0700 (PDT)
From:      "Rodney W. Grimes" <freebsd@pdx.rh.CN85.dnsmgr.net>
To:        "Andrey V. Elsukov" <ae@freebsd.org>
Cc:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   Re: svn commit: r318400 - head/sbin/ipfw
Message-ID:  <201705180049.v4I0nZa1063721@pdx.rh.CN85.dnsmgr.net>
In-Reply-To: <201705171056.v4HAuMOV078812@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
[ Charset UTF-8 unsupported, converting... ]
> Author: ae
> Date: Wed May 17 10:56:22 2017
> New Revision: 318400
> URL: https://svnweb.freebsd.org/changeset/base/318400
> 
> Log:
>   Allow zero port specification in table entries with type flow.
>   
>   PR:		217620
>   MFC after:	1 week
> 
> Modified:
>   head/sbin/ipfw/tables.c
> 
> Modified: head/sbin/ipfw/tables.c
> ==============================================================================
> --- head/sbin/ipfw/tables.c	Wed May 17 09:04:09 2017	(r318399)
> +++ head/sbin/ipfw/tables.c	Wed May 17 10:56:22 2017	(r318400)
> @@ -1260,16 +1260,14 @@ tentry_fill_key_type(char *arg, ipfw_obj
>  			if ((p = strchr(arg, ',')) != NULL)
>  				*p++ = '\0';
>  
> -			if ((port = htons(strtol(arg, NULL, 10))) == 0) {
> +			port = htons(strtol(arg, &pp, 10));
                                                      ^^^
Can this be converted to a sizeof(foo) somehow?
Constants like this are typically bad style and lead to bugs.

> +			if (*pp != '\0') {
>  				if ((sent = getservbyname(arg, NULL)) == NULL)
>  					errx(EX_DATAERR, "Unknown service: %s",
>  					    arg);
> -				else
> -					key = sent->s_port;
> +				port = sent->s_port;
>  			}
> -			
>  			tfe->sport = port;
> -
>  			arg = p;
>  		}
>  
> @@ -1304,16 +1302,14 @@ tentry_fill_key_type(char *arg, ipfw_obj
>  			if ((p = strchr(arg, ',')) != NULL)
>  				*p++ = '\0';
>  
> -			if ((port = htons(strtol(arg, NULL, 10))) == 0) {
> +			port = htons(strtol(arg, &pp, 10));
> +			if (*pp != '\0') {
>  				if ((sent = getservbyname(arg, NULL)) == NULL)
>  					errx(EX_DATAERR, "Unknown service: %s",
>  					    arg);
> -				else
> -					key = sent->s_port;
> +				port = sent->s_port;
>  			}
> -			
>  			tfe->dport = port;
> -
>  			arg = p;
>  		}
>  
> 
> 

-- 
Rod Grimes                                                 rgrimes@freebsd.org



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201705180049.v4I0nZa1063721>