From 27c10313957eebbde9f788f645316e03f32861d4 Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Fri, 8 Apr 2022 18:24:22 +0100 Subject: [PATCH] dvd-sector-copy.c: Calculate the clear-area size consistently. This should be determined as a (possibly fractional) multiple of the distance from the start of the bad region to the current position. Alas, the code for the bounding stage incorrectly used the distance from the previous position to the new one. The inconsistency between the bounding and refinement stages of the recovery algorithm could lead to failed invariants and a nonsense result. --- dvd-sector-copy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dvd-sector-copy.c b/dvd-sector-copy.c index 73e068a..40ee26d 100644 --- a/dvd-sector-copy.c +++ b/dvd-sector-copy.c @@ -743,8 +743,8 @@ static ssize_t find_good_sector(secaddr *pos_inout, secaddr end, step = (step_factor - 1)*(bad_hi - bad_lo); if (step < step_min) step = step_min; if (step_max && step > step_max) step = step_max; - if (step > end - bad_hi) step = end - bad_hi; - pos = bad_hi + step - 1; + step += bad_hi - bad_lo; + if (step > end - bad_lo) step = end - bad_lo; want = run_length_wanted(pos, step, end); n = recovery_read(&r, pos, want); #ifdef DEBUG -- 2.11.0