netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Feng Gao <gfree.wind@gmail.com>
Cc: kadlec@blackhole.kfki.hu,
	Netfilter Developer Mailing List
	<netfilter-devel@vger.kernel.org>,
	coreteam@netfilter.org
Subject: Re: [PATCH nf-next] netfilter: ftp: Remove the useless dlen==0 condition check in find_pattern
Date: Thu, 1 Sep 2016 12:20:01 +0200	[thread overview]
Message-ID: <20160901102001.GA2005@salvia> (raw)
In-Reply-To: <CA+6hz4o5ZqQBEND62wK3QswZd-vi0ark9aJWbjrPL9d_Aq2-ZQ@mail.gmail.com>

On Thu, Sep 01, 2016 at 10:26:08AM +0800, Feng Gao wrote:
> On Thu, Sep 1, 2016 at 10:14 AM,  <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.
> >
> > Signed-off-by: Gao Feng <fgao@ikuai8.com>
> > ---
> >  net/netfilter/nf_conntrack_ftp.c | 12 ------------
> >  1 file changed, 12 deletions(-)
> >
> > diff --git a/net/netfilter/nf_conntrack_ftp.c b/net/netfilter/nf_conntrack_ftp.c
> > index b6934b5..77f05ac 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? */
> > @@ -312,16 +310,6 @@ static int find_pattern(const char *data, size_t dlen,
> >         }
> >
> >         if (strncasecmp(data, pattern, plen) != 0) {
> > -#if 0
> > -               size_t i;
> > -
> > -               pr_debug("ftp: string mismatch\n");
> > -               for (i = 0; i < plen; i++) {
> > -                       pr_debug("ftp:char %u `%c'(%u) vs `%c'(%u)\n",
> > -                                i, data[i], data[i],
> > -                                pattern[i], pattern[i]);
> > -               }
> > -#endif
> >                 return 0;
> >         }
> >
> > --
> > 1.9.1
> >
> >
> 
> Sorry, I forget one point. I also remove some codes which are
> commented out by #if0.

Please, do this in a separated patch. Thanks.

  reply	other threads:[~2016-09-01 10:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-01  2:14 [PATCH nf-next] netfilter: ftp: Remove the useless dlen==0 condition check in find_pattern fgao
2016-09-01  2:26 ` Feng Gao
2016-09-01 10:20   ` Pablo Neira Ayuso [this message]
2016-09-01 11:01     ` Feng Gao
2016-09-01 11:08       ` 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=20160901102001.GA2005@salvia \
    --to=pablo@netfilter.org \
    --cc=coreteam@netfilter.org \
    --cc=gfree.wind@gmail.com \
    --cc=kadlec@blackhole.kfki.hu \
    --cc=netfilter-devel@vger.kernel.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).