]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(copy_reg): Rearrange arithmetic in conditional to avoid
authorJim Meyering <jim@meyering.net>
Fri, 19 Apr 1996 05:07:52 +0000 (05:07 +0000)
committerJim Meyering <jim@meyering.net>
Fri, 19 Apr 1996 05:07:52 +0000 (05:07 +0000)
integer overflow with large files.

src/cp.c

index a44046abed035a5edeb807b2581f47cba110ee8b..837d5fb107502ed536815b5c5184ec1a1cb8f2c7 100644 (file)
--- a/src/cp.c
+++ b/src/cp.c
@@ -1242,7 +1242,7 @@ copy_reg (char *src_path, char *dst_path)
         be needed for a file of its size, then
         at least one of the blocks in the file is a hole. */
       /* FIXME: isn't there risk of overflow here?  */
-      if (S_ISREG (sb.st_mode) && sb.st_size > ST_NBLOCKS (sb) * 512)
+      if (S_ISREG (sb.st_mode) && sb.st_size / 512 > ST_NBLOCKS (sb))
        make_holes = 1;
     }
 #endif