From: Mark Wooding Date: Fri, 18 Feb 2022 22:54:19 +0000 (+0000) Subject: dvd-sector-copy.c: Check `n' nonnegative before comparing with unsigned. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/dvdrip/commitdiff_plain/d935b4815a7e314cfe75f46ad6eb9bfb6f5f447b dvd-sector-copy.c: Check `n' nonnegative before comparing with unsigned. Otherwise it might be coerced to unsigned, at which point the comparison means something completely different. --- diff --git a/dvd-sector-copy.c b/dvd-sector-copy.c index c336d3d..177ce94 100644 --- a/dvd-sector-copy.c +++ b/dvd-sector-copy.c @@ -595,7 +595,7 @@ static ssize_t recovery_read(struct recoverybuf *r, printf(" -> %zd\n", n); #endif if (n != nn) { - if (n > want) n = want; + if (n >= 0 && n > want) n = want; goto end; } r->start = pp;