From: "Álvaro Neira Ayuso" <alvaroneay@gmail.com>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [libnftnl PATCH 1/2] src: not create iterator with empty list
Date: Sat, 10 Jan 2015 19:26:38 +0100 [thread overview]
Message-ID: <54B16EDE.7060207@gmail.com> (raw)
In-Reply-To: <20150110182022.GA5185@salvia>
El 10/01/15 a las 19:20, Pablo Neira Ayuso escribió:
> On Fri, Jan 09, 2015 at 01:47:40PM +0100, Alvaro Neira Ayuso wrote:
>> Now, we create iterator without test if the list is empty. If the list
>> is empty, we have a crash when we set up the current element.
>> With this patch, we test if the list is empty before to create the iterator. If
>> the list is empty the iterator return NULL.
>
> Please, handle this from the _next() function.
>
> The idea is to set iter->cur to NULL if the list is empty from
> iter_create, ie.
>
> if (iter->r->expr_list.next == &iter->r.expr_list)
> iter->cur = NULL;
> else
> iter->cur = list_entry(...);
>
> Then, from _next() you check for:
>
> if (expr == NULL)
> return NULL;
Ok, nice idea.
>
>> Signed-off-by: Alvaro Neira Ayuso <alvaroneay@gmail.com>
>> ---
>> src/chain.c | 3 +++
>> src/rule.c | 6 ++++++
>> src/set.c | 3 +++
>> src/set_elem.c | 3 +++
>> src/table.c | 3 +++
>
> I can count up to six iterator interfaces, I only see 5 here, please
> make sure you adapt all spots. Thanks.
>
mmm yes and I have changed the code in the six iterator interfaces. I
have changed:
- nft_chain_list_iter_create
- nft_rule_expr_iter_create
- nft_rule_list_iter_create
- nft_set_list_iter_create
- nft_set_elems_iter_create
- nft_table_list_iter_create
Have I forgot any?
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2015-01-10 18:34 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-09 12:47 [libnftnl PATCH 1/2] src: not create iterator with empty list Alvaro Neira Ayuso
2015-01-09 12:47 ` [libnftnl PATCH 2/2] ruleset: clean up the variable names in the xml/json parsing functions Alvaro Neira Ayuso
2015-01-10 18:23 ` Pablo Neira Ayuso
2015-01-10 18:20 ` [libnftnl PATCH 1/2] src: not create iterator with empty list Pablo Neira Ayuso
2015-01-10 18:26 ` Álvaro Neira Ayuso [this message]
2015-01-10 18:51 ` Pablo Neira Ayuso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=54B16EDE.7060207@gmail.com \
--to=alvaroneay@gmail.com \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).