Subject: Bug in /usr/src/lib/libc/string/bm.c?
To: None <netbsd-users@NetBSD.ORG>
From: Knut A. Syed <Knut.Syed@nhh.no>
List: netbsd-users
Date: 09/25/1997 16:34:43
I am having some problems using the Boyer-Moore string search routine
bm_exec().
The problem appears when searching for a string which is not found, in
an input-file with size > 4 kb.
To me the behavior looks like a bug, which can be fixed with the
following changes to bm.c:
185c185
< while (k) {
---
> while (k && (s < e))
187,188d186
< k = d0[*(s += k)];
< }
I have made a little test-program available at
<URL:ftp://kas.nhh.no/pub/NetBSD/1997-09-25-bm_test.tar.gz>. Can
someone who has a better understanding of the inner workings of the
algorithm and routines (jtc?) take a look at it, and see if my patch
is ok?
'make test' will compile and run two programs (bm_test_error and
bm_test_ok), the first with a native bm.c, the second with a modified
copy. bm_test_error crashes when searching for 'b' in a file
containing 4097 (i.e. 4k + 1) 'a'.
~kas