: Fix Boyer Moore initialization bug
Subsystems (2)
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.
[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.
---
commit 96d2404fab775fc7aebf06956bd3ea5e8996b0f7
tree 682dee25bd20e0d85f909fbf5967db2844d58253
parent 8ebd6bb0f469f2759f39e73adee6916a3d975393
author Michael Rash <[email protected]> Thu, 17 Aug 2006 17:43:21 +0200 committer Patrick McHardy <[email protected]> Thu, 17 Aug 2006 17:43:21 +0200
lib/ts_bm.c | 11 +++++------ 1 files changed, 5 insertions(+), 6 deletions(-)
lib/ts_bm.c +5 -6
@@ -111,15 +111,14 @@ static int subpattern(u8 *pattern, int ireturn 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; }
From: Patrick McHardy <[email protected]>
Date: Tue, 22 Aug 2006 04:07:57 +0200
Quoted 6 lines
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_tsauthor asked me to also submit this to -stable, please apply.
Applied and Ack'd for -stable.
Greg KH
AppliedQuoted 11 lines · David Miller
From: Patrick McHardy <[email protected]>
Date: Tue, 22 Aug 2006 04:07:57 +0200Quoted 6 lines
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_tsauthor asked me to also submit this to -stable, please apply.Applied and Ack'd for -stable.
Queued to -stable, thanks.
greg k-h
Adrian Bunk
AppliedQuoted 11 lines · David Miller
From: Patrick McHardy <[email protected]>
Date: Tue, 22 Aug 2006 04:07:57 +0200Quoted 6 lines
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_tsauthor asked me to also submit this to -stable, please apply.Applied and Ack'd for -stable.
Thanks, applied to 2.6.16.
cu
Adrian
Signature · 4 lines
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed