From a8625592998b9086b8f5f2df40f8f40709c15921 Mon Sep 17 00:00:00 2001 Message-Id: From: Mark Wooding Date: Fri, 18 Feb 2022 22:57:13 +0000 Subject: [PATCH 1/1] dvd-sector-copy.c: Fix final recovery. Organization: Straylight/Edgeware From: Mark Wooding Write this the other way around, because it's easier to read that way. And then notice that it's broken because it doesn't actually set the return value properly. --- dvd-sector-copy.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/dvd-sector-copy.c b/dvd-sector-copy.c index dd97d8b..98ee8ec 100644 --- a/dvd-sector-copy.c +++ b/dvd-sector-copy.c @@ -710,10 +710,12 @@ static ssize_t find_good_sector(secaddr *pos_inout, secaddr end, else bad_hi = pos + n + 1; } recovered(bad_lo, bad_hi); *pos_inout = good; - if (r.pos + r.start <= good && good <= r.pos + r.end) { - rearrange_sectors(&r, 0, good - r.pos, r.pos + r.end - good); - } else + if (good < r.pos + r.start || r.pos + r.end <= good) n = 0; + else { + n = r.pos + r.end - good; + rearrange_sectors(&r, 0, good - r.pos, n); + } return (n); } -- [mdw]