From: Patrick McHardy <kaber@trash.net>
To: "David S. Miller" <davem@davemloft.net>
Cc: Netfilter Development Mailinglist
<netfilter-devel@lists.netfilter.org>,
stable@kernel.org, Adrian Bunk <bunk@stusta.de>
Subject: [TEXTSEARCH]: Fix Boyer Moore initialization bug
Date: Tue, 22 Aug 2006 04:07:57 +0200 [thread overview]
Message-ID: <44EA66FD.8050502@trash.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 261 bytes --]
Hi Dave,
this fixes an initialization bug in the bm textsearch
algorithm affecting the netfilter string match (the
only user AFAIK). Please apply to 2.6.18, thanks.
@stable maintainers: the bm_ts author asked me to also
submit this to -stable, please apply.
[-- Attachment #2: x --]
[-- Type: text/plain, Size: 1771 bytes --]
[TEXTSEARCH]: Fix Boyer Moore initialization bug
The pattern is set after trying to compute the prefix table, which tries
to use it. Initialize it before calling compute_prefix_tbl, make
compute_prefix_tbl consistently use only the data from struct ts_bm
and remove the now unnecessary arguments.
Signed-off-by: Michael Rash <mbr@cipherdyne.org>
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit 96d2404fab775fc7aebf06956bd3ea5e8996b0f7
tree 682dee25bd20e0d85f909fbf5967db2844d58253
parent 8ebd6bb0f469f2759f39e73adee6916a3d975393
author Michael Rash <mbr@cipherdyne.org> Thu, 17 Aug 2006 17:43:21 +0200
committer Patrick McHardy <kaber@trash.net> Thu, 17 Aug 2006 17:43:21 +0200
lib/ts_bm.c | 11 +++++------
1 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/lib/ts_bm.c b/lib/ts_bm.c
index 0110e44..d90822c 100644
--- a/lib/ts_bm.c
+++ b/lib/ts_bm.c
@@ -111,15 +111,14 @@ static int subpattern(u8 *pattern, int i
return ret;
}
-static void compute_prefix_tbl(struct ts_bm *bm, const u8 *pattern,
- unsigned int len)
+static void compute_prefix_tbl(struct ts_bm *bm)
{
int i, j, g;
for (i = 0; i < ASIZE; i++)
- bm->bad_shift[i] = len;
- for (i = 0; i < len - 1; i++)
- bm->bad_shift[pattern[i]] = len - 1 - i;
+ bm->bad_shift[i] = bm->patlen;
+ for (i = 0; i < bm->patlen - 1; i++)
+ bm->bad_shift[bm->pattern[i]] = bm->patlen - 1 - i;
/* Compute the good shift array, used to match reocurrences
* of a subpattern */
@@ -150,8 +149,8 @@ static struct ts_config *bm_init(const v
bm = ts_config_priv(conf);
bm->patlen = len;
bm->pattern = (u8 *) bm->good_shift + prefix_tbl_len;
- compute_prefix_tbl(bm, pattern, len);
memcpy(bm->pattern, pattern, len);
+ compute_prefix_tbl(bm);
return conf;
}
next reply other threads:[~2006-08-22 2:07 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-22 2:07 Patrick McHardy [this message]
2006-08-22 7:45 ` [TEXTSEARCH]: Fix Boyer Moore initialization bug David Miller
2006-08-25 22:09 ` [stable] " Greg KH
2006-09-18 17:26 ` Adrian Bunk
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=44EA66FD.8050502@trash.net \
--to=kaber@trash.net \
--cc=bunk@stusta.de \
--cc=davem@davemloft.net \
--cc=netfilter-devel@lists.netfilter.org \
--cc=stable@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 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.