* [PATCH v2 1/2 nf-next] netfilter: ftp: Remove the useless dlen==0 condition check in find_pattern
@ 2016-09-01 10:58 fgao
2016-09-07 8:48 ` Pablo Neira Ayuso
0 siblings, 1 reply; 2+ messages in thread
From: fgao @ 2016-09-01 10:58 UTC (permalink / raw)
To: pablo, kadlec, netfilter-devel, coreteam; +Cc: gfree.wind, Gao Feng
From: Gao Feng <fgao@ikuai8.com>
The caller function "help" has already make sure the datalen could not be zero
before invoke find_pattern as a parameter by the following codes
if (dataoff >= skb->len) {
pr_debug("ftp: dataoff(%u) >= skblen(%u)\n", dataoff,
skb->len);
return NF_ACCEPT;
}
datalen = skb->len - dataoff;
And the latter codes "ends_in_nl = (fb_ptr[datalen - 1] == '\n');" use datalen
directly without checking if it is zero.
So it is unneccessary to check it in find_pattern too.
Signed-off-by: Gao Feng <fgao@ikuai8.com>
---
v2: Split original patch to two commits;
v1: Initial patch
net/netfilter/nf_conntrack_ftp.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/net/netfilter/nf_conntrack_ftp.c b/net/netfilter/nf_conntrack_ftp.c
index b6934b5..d49a2d4 100644
--- a/net/netfilter/nf_conntrack_ftp.c
+++ b/net/netfilter/nf_conntrack_ftp.c
@@ -301,8 +301,6 @@ static int find_pattern(const char *data, size_t dlen,
size_t i = plen;
pr_debug("find_pattern `%s': dlen = %Zu\n", pattern, dlen);
- if (dlen == 0)
- return 0;
if (dlen <= plen) {
/* Short packet: try for partial? */
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2 1/2 nf-next] netfilter: ftp: Remove the useless dlen==0 condition check in find_pattern
2016-09-01 10:58 [PATCH v2 1/2 nf-next] netfilter: ftp: Remove the useless dlen==0 condition check in find_pattern fgao
@ 2016-09-07 8:48 ` Pablo Neira Ayuso
0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2016-09-07 8:48 UTC (permalink / raw)
To: fgao; +Cc: kadlec, netfilter-devel, coreteam, gfree.wind
On Thu, Sep 01, 2016 at 06:58:29PM +0800, fgao@ikuai8.com wrote:
> From: Gao Feng <fgao@ikuai8.com>
>
> The caller function "help" has already make sure the datalen could not be zero
> before invoke find_pattern as a parameter by the following codes
>
> if (dataoff >= skb->len) {
> pr_debug("ftp: dataoff(%u) >= skblen(%u)\n", dataoff,
> skb->len);
> return NF_ACCEPT;
> }
> datalen = skb->len - dataoff;
>
> And the latter codes "ends_in_nl = (fb_ptr[datalen - 1] == '\n');" use datalen
> directly without checking if it is zero.
>
> So it is unneccessary to check it in find_pattern too.
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-09-07 8:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-01 10:58 [PATCH v2 1/2 nf-next] netfilter: ftp: Remove the useless dlen==0 condition check in find_pattern fgao
2016-09-07 8:48 ` Pablo Neira Ayuso
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.