Re: [PATCH 1/2 libnftnl] expr: Improve bound checking in stringification functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Aug 15, 2016 at 12:27:36PM +0200, Carlos Falgueras García wrote:
> --- a/src/utils.c
> +++ b/src/utils.c
> @@ -23,6 +23,7 @@
>  #include <linux/netfilter/nf_tables.h>
>  
>  static const char *const nftnl_family_str[NFPROTO_NUMPROTO] = {
> +	[NFPROTO_UNSPEC]	= "unknown",
>  	[NFPROTO_INET]		= "inet",
>  	[NFPROTO_IPV4]		= "ip",
>  	[NFPROTO_ARP]		= "arp",
> @@ -33,7 +34,7 @@ static const char *const nftnl_family_str[NFPROTO_NUMPROTO] = {
>  
>  const char *nftnl_family2str(uint32_t family)
>  {
> -	if (nftnl_family_str[family] == NULL)
> +	if (family >= NFPROTO_NUMPROTO || !nftnl_family_str[family])
>  		return "unknown";
>  
>  	return nftnl_family_str[family];

You only need this chunk.

Other spots have continuous enums, so there is no problem.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux