From: Paul Eggert Date: Thu, 3 Oct 2019 19:35:44 +0000 (-0700) Subject: cp: simplify integer overflow checking X-Git-Tag: v8.32~51 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bb23a7563f9abcfc68c2caa443b0cbb6d6206fd1;p=thirdparty%2Fcoreutils.git cp: simplify integer overflow checking * src/copy.c (sparse_copy): Use INT_ADD_WRAPV instead of doing overflow checking by hand. --- diff --git a/src/copy.c b/src/copy.c index 65cf658953..cd6104c7a6 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;