>From 1316620e81daf91317560226b2b63cbbf548c09d Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 3 Oct 2019 12:35:44 -0700 Subject: [PATCH 1/4] cp: simplify integer overflow checking * src/copy.c (sparse_copy): Use INT_ADD_WRAPV instead of doing overflow checking by hand. --- src/copy.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/copy.c b/src/copy.c index 65cf65895..cd6104c7a 100644 --- a/src/copy.c +++ b/src/copy.c @@ -335,9 +335,7 @@ sparse_copy (int src_fd, int dest_fd, char *buf, size_t buf_size, } else /* Coalesce writes/seeks. */ { - if (psize <= OFF_T_MAX - csize) - psize += csize; - else + if (INT_ADD_WRAPV (psize, csize, &psize)) { error (0, 0, _("overflow reading %s"), quoteaf (src_name)); return false; -- 2.21.0