Re: [PATCH 2/3 libnftnl] fix some error checking in parser functions

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

 



On Thu, Jun 16, 2016 at 12:20:11PM +0200, Carlos Falgueras García wrote:
> diff --git a/src/rule.c b/src/rule.c
> index b009c37..930ecc0 100644
> --- a/src/rule.c
> +++ b/src/rule.c
> @@ -427,7 +427,7 @@ int nftnl_rule_nlmsg_parse(const struct nlmsghdr *nlh, struct nftnl_rule *r)
>  {
>  	struct nlattr *tb[NFTA_RULE_MAX+1] = {};
>  	struct nfgenmsg *nfg = mnl_nlmsg_get_payload(nlh);
> -	int ret = 0;
> +	int ret;
>  
>  	if (mnl_attr_parse(nlh, sizeof(*nfg), nftnl_rule_parse_attr_cb, tb) < 0)
>  		return -1;
> @@ -452,10 +452,16 @@ int nftnl_rule_nlmsg_parse(const struct nlmsghdr *nlh, struct nftnl_rule *r)
>  		r->handle = be64toh(mnl_attr_get_u64(tb[NFTA_RULE_HANDLE]));
>  		r->flags |= (1 << NFTNL_RULE_HANDLE);
>  	}
> -	if (tb[NFTA_RULE_EXPRESSIONS])
> +	if (tb[NFTA_RULE_EXPRESSIONS]) {
>  		ret = nftnl_rule_parse_expr(tb[NFTA_RULE_EXPRESSIONS], r);
> -	if (tb[NFTA_RULE_COMPAT])
> +		if (ret)
> +			return ret;

Please use:
                if (ret < 0)
                        return ret;

instead. I think this is the common idiom we're using all around this
library.

Thanks.
--
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