From: Joonwoo Park Date: Mon, 7 Jul 2008 13:56:57 +0000 (+0200) Subject: textsearch: fix Boyer-Moore text search bug X-Git-Tag: v2.6.25.12~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3fa6bcb587adefb2ed2391297529cbead8f03e0a;p=thirdparty%2Fkernel%2Fstable.git textsearch: fix Boyer-Moore text search bug Upstream commit aebb6a849cfe7d89bcacaaecc20a480dfc1180e7 The current logic has a bug which cannot find matching pattern, if the pattern is matched from the first character of target string. for example: pattern=abc, string=abcdefg pattern=a, string=abcdefg Searching algorithm should return 0 for those things. Signed-off-by: Joonwoo Park Signed-off-by: Patrick McHardy Signed-off-by: David S. Miller --- diff --git a/lib/ts_bm.c b/lib/ts_bm.c index d90822c378a48..4a7fce72898ed 100644 --- a/lib/ts_bm.c +++ b/lib/ts_bm.c @@ -63,7 +63,7 @@ static unsigned int bm_find(struct ts_config *conf, struct ts_state *state) struct ts_bm *bm = ts_config_priv(conf); unsigned int i, text_len, consumed = state->offset; const u8 *text; - int shift = bm->patlen, bs; + int shift = bm->patlen - 1, bs; for (;;) { text_len = conf->get_next_block(consumed, &text, conf, state);