From: Jim Meyering Date: Sun, 30 Nov 1997 10:24:50 +0000 (+0000) Subject: (copy_reg): Store file size as off_t, not long. X-Git-Tag: TEXTUTILS-1_22c~31 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b8c474191af9b458b0b9a82eaa1e28a44730f544;p=thirdparty%2Fcoreutils.git (copy_reg): Store file size as off_t, not long. Do not assume st_size has been normalized to 512 byte blocks, or that it fits in size_t after dividing by the blocksize. --- diff --git a/src/copy.c b/src/copy.c index 24f5756cb1..31d05a6e8c 100644 --- a/src/copy.c +++ b/src/copy.c @@ -77,7 +77,7 @@ copy_dir (const char *src_path_in, const char *dst_path_in, int new_dst, int ret = 0; errno = 0; - name_space = savedir (src_path_in, src_sb->st_size); + name_space = savedir (src_path_in, (unsigned int) src_sb->st_size); if (name_space == 0) { if (errno) @@ -132,7 +132,7 @@ copy_reg (const char *src_path, const char *dst_path, char *cp; int *ip; int return_val = 0; - long n_read_total = 0; + off_t n_read_total = 0; int last_write_made_hole = 0; int make_holes = (sparse_mode == SPARSE_ALWAYS); @@ -182,7 +182,7 @@ copy_reg (const char *src_path, const char *dst_path, be needed for a file of its size, then at least one of the blocks in the file is a hole. */ if (S_ISREG (sb.st_mode) - && (size_t) (sb.st_size / 512) > (size_t) ST_NBLOCKS (sb)) + && sb.st_size / ST_NBLOCKSIZE > ST_NBLOCKS (sb)) make_holes = 1; } #endif