diff --git a/src/copyout.c b/src/copyout.c index 72f1989..ee6f24a 100644 --- a/src/copyout.c +++ b/src/copyout.c @@ -59,7 +59,7 @@ read_for_checksum (int in_file_des, int file_size, char *file_name) if (lseek (in_file_des, 0L, SEEK_SET)) error (1, errno, _("cannot read checksum for %s"), file_name); - return crc; + return crc & CHKSUM_MAX; } /* Write out NULs to fill out the rest of the current block on @@ -381,7 +381,7 @@ write_out_new_ascii_header (const char *magic_string, _("name size"))) return 1; p += 8; - to_ascii (p, file_hdr->c_chksum & 0xffffffff, 8, LG_16); + to_ascii (p, file_hdr->c_chksum & CHKSUM_MAX, 8, LG_16); tape_buffered_write (ascii_header, out_des, sizeof ascii_header); diff --git a/src/extern.h b/src/extern.h index 4f94d40..b274690 100644 --- a/src/extern.h +++ b/src/extern.h @@ -205,6 +205,8 @@ int cpio_create_dir (struct cpio_file_stat *file_hdr, int existing_dir); #define LG_8 3 #define LG_16 4 +#define CHKSUM_MAX 0xffffffffu + uintmax_t from_ascii (char const *where, size_t digs, unsigned logbase); #define FROM_OCTAL(f) from_ascii (f, sizeof f, LG_8) diff --git a/src/util.c b/src/util.c index 00953d5..e307c58 100644 --- a/src/util.c +++ b/src/util.c @@ -413,6 +413,8 @@ tape_toss_input (int in_des, off_t num_bytes) input_size -= space_left; bytes_left -= space_left; } + + crc &= CHKSUM_MAX; } void @@ -461,6 +463,8 @@ copy_files_tape_to_disk (int in_des, int out_des, off_t num_bytes) input_size -= size; in_buff += size; } + + crc &= CHKSUM_MAX; } /* Copy a file using the input and output buffers, which may start out partly full. After the copy, the files are not closed nor the last @@ -514,6 +518,8 @@ copy_files_disk_to_tape (int in_des, int out_des, off_t num_bytes, input_size -= size; in_buff += size; } + + crc &= CHKSUM_MAX; } /* Copy a file using the input and output buffers, which may start out partly full. After the copy, the files are not closed nor the last @@ -564,6 +570,8 @@ copy_files_disk_to_disk (int in_des, int out_des, off_t num_bytes, input_size -= size; in_buff += size; } + + crc &= CHKSUM_MAX; } /* Warn if file changed while it was being copied. */