From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Patrick McHardy <kaber@trash.net>
Cc: andrei.popa@i-neo.ro, netfilter-devel@vger.kernel.org
Subject: Re: [oops] in text matching
Date: Sun, 25 Nov 2007 20:30:25 +0100 [thread overview]
Message-ID: <4749CD51.1000906@netfilter.org> (raw)
In-Reply-To: <47499708.5070502@trash.net>
[-- Attachment #1: Type: text/plain, Size: 1129 bytes --]
Hi Patrick,
Patrick McHardy wrote:
> Patrick McHardy wrote:
>> Andrei Popa wrote:
>>> On Sat, 2007-11-10 at 13:57 +0100, Patrick McHardy wrote:
>>>> Please try this patch.
>>>
>>> it's ok now:
>>>
>>> test ~ # iptables -I INPUT -p tcp --dport 80 -m string --algo bm
>>> --string "$MyNick" -j DROP
>>> iptables: Invalid argument
>>
>>
>> Thanks, thats whats expected. The patch is suboptimal though
>> since it should really allow patterns of length zero. Pablo,
>> the naive approach would be to ignore patlen == 0 in the
>> initialization path and return the current position in bm_find().
>> But I'm guessing there's a better way to handle this case,
>> could you look into this please? Thanks.
>
>
> Pablo? I would prefer to get this fixed before 2.6.24, unless
> there's a better fix I'm going to include my patch to reject
> pattern lengths of 0. Thanks.
Sorry for the late reply. Why should we accept zero length patterns?
Would you consider this patch? It keeps consistent the return value of
all textsearch approaches when a zero length pattern is passed.
--
"Los honestos son inadaptados sociales" -- Les Luthiers
[-- Attachment #2: y --]
[-- Type: text/plain, Size: 1337 bytes --]
[PATCH] Do not allow zero length patterns in the textsearch infrastructure
If a zero length pattern is passed then return EINVAL.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
diff --git a/lib/textsearch.c b/lib/textsearch.c
index 88c98a2..be8bda3 100644
--- a/lib/textsearch.c
+++ b/lib/textsearch.c
@@ -7,7 +7,7 @@
* 2 of the License, or (at your option) any later version.
*
* Authors: Thomas Graf <tgraf@suug.ch>
- * Pablo Neira Ayuso <pablo@eurodev.net>
+ * Pablo Neira Ayuso <pablo@netfilter.org>
*
* ==========================================================================
*
@@ -250,7 +250,8 @@ unsigned int textsearch_find_continuous(struct ts_config *conf,
* the various search algorithms.
*
* Returns a new textsearch configuration according to the specified
- * parameters or a ERR_PTR().
+ * parameters or a ERR_PTR(). If a zero length pattern is passed, this
+ * function returns EINVAL.
*/
struct ts_config *textsearch_prepare(const char *algo, const void *pattern,
unsigned int len, gfp_t gfp_mask, int flags)
@@ -259,6 +260,9 @@ struct ts_config *textsearch_prepare(const char *algo, const void *pattern,
struct ts_config *conf;
struct ts_ops *ops;
+ if (len == 0)
+ return ERR_PTR(-EINVAL);
+
ops = lookup_ts_algo(algo);
#ifdef CONFIG_KMOD
/*
next prev parent reply other threads:[~2007-11-25 19:30 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-08 12:40 [oops] in text matching Andrei Popa
2007-11-08 13:32 ` Patrick McHardy
2007-11-08 18:50 ` Andrei Popa
2007-11-08 18:53 ` Andrei Popa
2007-11-08 19:06 ` Andrei Popa
2007-11-10 12:57 ` Patrick McHardy
2007-11-13 6:51 ` Andrei Popa
2007-11-13 6:56 ` Patrick McHardy
2007-11-25 15:38 ` Patrick McHardy
2007-11-25 19:30 ` Pablo Neira Ayuso [this message]
2007-11-26 7:43 ` Patrick McHardy
2007-11-28 17:07 ` Pablo Neira Ayuso
2007-11-28 18:38 ` Patrick McHardy
2007-11-29 23:51 ` Patrick McHardy
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=4749CD51.1000906@netfilter.org \
--to=pablo@netfilter.org \
--cc=andrei.popa@i-neo.ro \
--cc=kaber@trash.net \
--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).