From 74f78bd74bf9db600cda6eabbf758e82a726b207 Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Sat, 19 Mar 2022 14:08:43 +0000 Subject: [PATCH] dvd-sector-copy.c: Use `bad_hi' consistently for the upper bound when done. It's just conceivable that `good' is less than `bad_hi' at this point, which screws everything up. It's essential to pick a consistent upper bound here. --- dvd-sector-copy.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/dvd-sector-copy.c b/dvd-sector-copy.c index 4c19389..4543296 100644 --- a/dvd-sector-copy.c +++ b/dvd-sector-copy.c @@ -730,16 +730,16 @@ static ssize_t find_good_sector(secaddr *pos_inout, secaddr end, if (n == want) good = pos; else bad_hi = pos + n + 1; } - recovered(bad_lo, bad_hi); *pos_inout = good; - if (good < r.pos + r.start || r.pos + r.end <= good) + recovered(bad_lo, bad_hi); *pos_inout = bad_hi; + if (bad_hi < r.pos + r.start || r.pos + r.end <= bad_hi) n = 0; else { - n = r.pos + r.end - good; - rearrange_sectors(&r, 0, good - r.pos, n); + n = r.pos + r.end - bad_hi; + rearrange_sectors(&r, 0, bad_hi - r.pos, n); } #ifdef DEBUG show_recovery_buffer_map(&r, "returning %zd good sectors at %"PRIuSEC"", - n, good); + n, bad_hi); #endif return (n); } -- 2.11.0