[cpio] cpio: trim checksum to 32 bit

Pavel Raiskup praiskup at fedoraproject.org
Fri Sep 20 19:52:56 UTC 2013


commit fff6894380fa9278c7a714c60455f72ec1b3e816
Author: Pavel Raiskup <praiskup at redhat.com>
Date:   Fri Sep 20 21:30:21 2013 +0200

    cpio: trim checksum to 32 bit
    
    Resolves: #1001965
    Version: 2.11-22

 cpio-2.11-crc-large-files.patch |   75 +++++++++++++++++++++++++++++++++++++++
 cpio.spec                       |   12 +++++-
 2 files changed, 85 insertions(+), 2 deletions(-)
---
diff --git a/cpio-2.11-crc-large-files.patch b/cpio-2.11-crc-large-files.patch
new file mode 100644
index 0000000..b39a702
--- /dev/null
+++ b/cpio-2.11-crc-large-files.patch
@@ -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.  */
diff --git a/cpio.spec b/cpio.spec
index 1cfa7d0..2021bb5 100644
--- a/cpio.spec
+++ b/cpio.spec
@@ -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 at redhat.com> - 2.11-22
+- properly trim "crc" checksum to 32 bits (#1001965)
+
 * Sat Aug 03 2013 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 2.11-21
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild
 


More information about the scm-commits mailing list