]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
textsearch: fix Boyer-Moore text search bug
authorJoonwoo Park <joonwpark81@gmail.com>
Mon, 7 Jul 2008 13:56:57 +0000 (15:56 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 24 Jul 2008 16:14:07 +0000 (09:14 -0700)
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 <joonwpark81@gmail.com>
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
lib/ts_bm.c

index d90822c378a48af52878f41e5db18858496fddb9..4a7fce72898ed40f13d58bca7cc1d97293d8bba0 100644 (file)
@@ -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);