bsdiff
bsdiff copied to clipboard
Fix incorrect binary search logic which would cause the longest matching 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)
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