Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test case failure; with (very rough) proposed fix #1

Open
spoonguard opened this issue Feb 23, 2011 · 1 comment
Open

Test case failure; with (very rough) proposed fix #1

spoonguard opened this issue Feb 23, 2011 · 1 comment

Comments

@spoonguard
Copy link

The following test case seems to fail -- specifically, the invocation of has_trailing? seems to incorrectly report false:

s = Mongrel::BMHSearch.new('--X', 512)

s.find('--X') # No trailing

s.find('B--') # Trailing; works correctly

s.find('X--') # Trailing

raise 'fail' unless (s.has_trailing?) # Fails

The correctness of s.has_trailing? makes buffer management in the caller much simpler and/or more efficient in some cases.

Commenting out the following line in ext/bmh_search/bmh_search.c (around line 199) and ending brace:

// don't bother if the string ends in the needle completely

if(S->nfound == 0 || last != hlen - S->nlen) {

...

}

...seems to fix the problem for this test case, and all of the ones in the application I'm currently working on. I haven't had a chance to run the fuzzers/tests that come up on pastie.org yet, but I plan to.

Dave
(who is writing stream-based multipart mime handling code, and happened to run in to this...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@spoonguard and others