* [PATCH nf] netfilter: nf_expect_proc: remove the redundant slash when policy name is empty
@ 2016-08-08 13:57 Liping Zhang
2016-08-08 14:06 ` Pablo Neira Ayuso
0 siblings, 1 reply; 2+ messages in thread
From: Liping Zhang @ 2016-08-08 13:57 UTC (permalink / raw)
To: pablo; +Cc: netfilter-devel, Liping Zhang
From: Liping Zhang <liping.zhang@spreadtrum.com>
The 'name' filed in struct nf_conntrack_expect_policy{} is not a
pointer, so check it is NULL or not will always return true. Even if the
name is empty, slash will always be displayed like follows:
# cat /proc/net/nf_conntrack_expect
297 l3proto = 2 proto=6 src=1.1.1.1 dst=2.2.2.2 sport=1 dport=1025 ftp/
^
Fixes: 3a8fc53a45c4 ("netfilter: nf_ct_helper: allocate 16 bytes for the helper and policy names")
Signed-off-by: Liping Zhang <liping.zhang@spreadtrum.com>
---
net/netfilter/nf_conntrack_expect.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/netfilter/nf_conntrack_expect.c b/net/netfilter/nf_conntrack_expect.c
index 9e36931..a4f3cc8 100644
--- a/net/netfilter/nf_conntrack_expect.c
+++ b/net/netfilter/nf_conntrack_expect.c
@@ -574,7 +574,7 @@ static int exp_seq_show(struct seq_file *s, void *v)
helper = rcu_dereference(nfct_help(expect->master)->helper);
if (helper) {
seq_printf(s, "%s%s", expect->flags ? " " : "", helper->name);
- if (helper->expect_policy[expect->class].name)
+ if (helper->expect_policy[expect->class].name[0] != '\0')
seq_printf(s, "/%s",
helper->expect_policy[expect->class].name);
}
--
2.5.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH nf] netfilter: nf_expect_proc: remove the redundant slash when policy name is empty
2016-08-08 13:57 [PATCH nf] netfilter: nf_expect_proc: remove the redundant slash when policy name is empty Liping Zhang
@ 2016-08-08 14:06 ` Pablo Neira Ayuso
0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2016-08-08 14:06 UTC (permalink / raw)
To: Liping Zhang; +Cc: netfilter-devel, Liping Zhang
On Mon, Aug 08, 2016 at 09:57:58PM +0800, Liping Zhang wrote:
> From: Liping Zhang <liping.zhang@spreadtrum.com>
>
> The 'name' filed in struct nf_conntrack_expect_policy{} is not a
> pointer, so check it is NULL or not will always return true. Even if the
> name is empty, slash will always be displayed like follows:
> # cat /proc/net/nf_conntrack_expect
> 297 l3proto = 2 proto=6 src=1.1.1.1 dst=2.2.2.2 sport=1 dport=1025 ftp/
> ^
>
> Fixes: 3a8fc53a45c4 ("netfilter: nf_ct_helper: allocate 16 bytes for the helper and policy names")
> Signed-off-by: Liping Zhang <liping.zhang@spreadtrum.com>
> ---
> net/netfilter/nf_conntrack_expect.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/netfilter/nf_conntrack_expect.c b/net/netfilter/nf_conntrack_expect.c
> index 9e36931..a4f3cc8 100644
> --- a/net/netfilter/nf_conntrack_expect.c
> +++ b/net/netfilter/nf_conntrack_expect.c
> @@ -574,7 +574,7 @@ static int exp_seq_show(struct seq_file *s, void *v)
> helper = rcu_dereference(nfct_help(expect->master)->helper);
> if (helper) {
> seq_printf(s, "%s%s", expect->flags ? " " : "", helper->name);
> - if (helper->expect_policy[expect->class].name)
> + if (helper->expect_policy[expect->class].name[0] != '\0')
Good catch. I can simplify this here to:
if (helper->expect_policy[expect->class].name[0])
We use similar idiom in other locations in the netfilter code. No need
to resend if OK with it.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-08-08 14:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-08 13:57 [PATCH nf] netfilter: nf_expect_proc: remove the redundant slash when policy name is empty Liping Zhang
2016-08-08 14:06 ` Pablo Neira Ayuso
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).