cpio: trim checksum to 32 bit

Resolves: #1001965
Version: 2.11-22
This commit is contained in:
Pavel Raiskup 2013-09-20 21:30:21 +02:00
parent be8336ee6b
commit fff6894380
2 changed files with 85 additions and 2 deletions

View File

@ -0,0 +1,75 @@
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. */

View File

@ -1,7 +1,7 @@
Summary: A GNU archiving program
Name: cpio
Version: 2.11
Release: 21%{?dist}
Release: 22%{?dist}
License: GPLv3+
Group: Applications/Archiving
URL: http://www.gnu.org/software/cpio/
@ -30,6 +30,10 @@ Patch8: cpio-2.11-crc-fips-nit.patch
# ~> #925189
Patch9: cpio-2.11-arm-config-sub-guess.patch
# Properly trim "crc" checksum to 32 bit number
# ~> downstream
Patch10: cpio-2.11-crc-large-files.patch
Requires(post): /sbin/install-info
Requires(preun): /sbin/install-info
Provides: bundled(gnulib)
@ -62,11 +66,12 @@ Install cpio if you need a program to manage file archives.
%patch7 -p1 -b .longnames
%patch8 -p1 -b .sum32-fips
%patch9 -p1 -b .arm-config-guess-sub
%patch10 -p1 -b .crc-big-files
autoreconf -v
%build
export CFLAGS="$RPM_OPT_FLAGS -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -pedantic -fno-strict-aliasing -Wall"
export CFLAGS="$RPM_OPT_FLAGS -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -pedantic -fno-strict-aliasing -Wall $CFLAGS"
%configure --with-rmt="%{_sysconfdir}/rmt"
make %{?_smp_mflags}
@ -110,6 +115,9 @@ fi
%{_infodir}/*.info*
%changelog
* Fri Sep 20 2013 Pavel Raiskup <praiskup@redhat.com> - 2.11-22
- properly trim "crc" checksum to 32 bits (#1001965)
* Sat Aug 03 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.11-21
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild