From 344c3a7e95f9d8e20a1a7bd1a9480c6509b21146 Mon Sep 17 00:00:00 2001 From: Thomas Schoebel-Theuer Date: Fri, 16 Apr 2021 11:23:17 +0200 Subject: [PATCH] copy: safeguard underflow --- kernel/mars_copy.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/mars_copy.c b/kernel/mars_copy.c index 2a7ef6f9..3e20a3b0 100644 --- a/kernel/mars_copy.c +++ b/kernel/mars_copy.c @@ -750,7 +750,8 @@ int _run_copy(struct copy_brick *brick, loff_t this_start) prev = -1; if (this_start > brick->copy_last) { - prev = GET_INDEX(this_start - COPY_CHUNK); + if (this_start >= COPY_CHUNK) + prev = GET_INDEX(this_start - COPY_CHUNK); max -= (this_start - brick->copy_last) / COPY_CHUNK; all_max = max; }