commit 9f49f0d0b82ceb2dfd93c50cb47dcbb84f511531
parent 155669edfab02aaa2eb5e39ccd67f3e2c8e1ffb0
Author: Thieu Le <thieule@chromium.org>
Date: Thu, 24 Sep 2020 16:52:43 +1000
Expand pathological case where files differ by <8 bytes
Modify bsdiff to better handle the case where files differ by <8 bytes
in some regions, not limitting this case to linear traversal.
Change-Id: I5b796977fc0e81d08b2e22abae48ae9e7dd2dba6
Reviewed-on: https://gerrit.chromium.org/gerrit/19270
Reviewed-by: Don Garrett <dgarrett@chromium.org>
Commit-Ready: Thieu Le <thieule@chromium.org>
Tested-by: Thieu Le <thieule@chromium.org>
Diffstat:
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/bsdiff.c b/bsdiff.c
@@ -177,11 +177,12 @@ main(int argc, char **argv)
old[scan + lastoffset] == new[scan])
oldscore--;
- if (len == prev_len - 1 &&
- oldscore == prev_oldscore - 1 &&
- pos == prev_pos + 1 &&
- len > oldscore &&
- len <= oldscore + 8)
+ const off_t fuzz = 8;
+ if (prev_len - fuzz <= len && len <= prev_len &&
+ prev_oldscore - fuzz <= oldscore &&
+ oldscore <= prev_oldscore &&
+ prev_pos <= pos && pos <= prev_pos + fuzz &&
+ oldscore <= len && len <= oldscore + fuzz)
num_less_than_eight++;
else
num_less_than_eight = 0;