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

Fix incorrect binary search logic which would cause the longest matching string to be missed #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

etnlGD
Copy link

@etnlGD etnlGD commented Sep 6, 2023

When memcmp returns 0 and cmpsize < newsize, it means that old + I[x] is smaller than new, then search(..., x, en, pos) should be performed instead of search(..., st, x, pos)

…ing string to be missed

When memcmp returns 0 and cmpsize < newsize, it means that `old + I[x]` is smaller than `new`, then `search(..., x, en, pos)` should be performed instead of `search(..., st, x, pos)`
@etnlGD
Copy link
Author

etnlGD commented Sep 6, 2023

You can reproduce this bug by constructing the following two files:

  • old.txt: 20MB, all characters are '0' except the last two characters are '1' and '0'. It's something like this: "0000000...000010"

  • new.txt: 20MB, all characters are '0'

bsdiff old.txt new.txt patch.out will take very very long time

edcdecl added a commit to edcdecl/bsdiff that referenced this pull request Feb 20, 2024
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

Successfully merging this pull request may close these issues.

1 participant