Bug#575267: cpio CRC checksum fixed upstream, not in Debian

2019-08-19 Thread Sebastian Andrzej Siewior
control: tags -1 patch
control: fixed -1 2.12+dfsg-1
control: forwarded -1 
http://git.savannah.gnu.org/cgit/cpio.git/commit/?id=ccec71ec318fdf739f55858d5bffaf4fd6520036

On 2013-05-22 14:32:48 [+0200], appzer0 wrote:
> Upstream patch (applied on git but never released, as cpio 2.11 is pretty
> old) can be found there :
> http://git.gnu.org.ua/gitweb?p=cpio.git;a=commitdiff;h=refs/heads/master

could this be fixed for Stretch, please?

> appzer0

Sebastian
>From ccec71ec318fdf739f55858d5bffaf4fd6520036 Mon Sep 17 00:00:00 2001
From: Sergey Poznyakoff 
Date: Mon, 20 Feb 2012 19:51:27 +0200
Subject: Always use 32 bit CRC

* src/cpiohdr.h (cpio_file_stat) : Change type to
uint32_t.
* src/extern.h (crc): Change type to uint32_t.
* src/global.c: Likewise.
* src/copyout.c (read_for_checksum): Return uint32_t.
* src/copyin.c: Fix printf formats.
---
 src/copyin.c  | 8 
 src/copyout.c | 4 ++--
 src/cpiohdr.h | 2 +-
 src/extern.h  | 2 +-
 src/global.c  | 2 +-
 5 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/copyin.c b/src/copyin.c
index 3ab5dac..3282816 100644
--- a/src/copyin.c
+++ b/src/copyin.c
@@ -178,7 +178,7 @@ list_file(struct cpio_file_stat* file_hdr, int in_file_des)
 #endif
   if (crc != file_hdr->c_chksum)
 	{
-	  error (0, 0, _("%s: checksum error (0x%lx, should be 0x%lx)"),
+	  error (0, 0, _("%s: checksum error (0x%x, should be 0x%x)"),
 		 file_hdr->c_name, crc, file_hdr->c_chksum);
 	}
 }
@@ -525,7 +525,7 @@ copyin_regular_file (struct cpio_file_stat* file_hdr, int in_file_des)
   if (archive_format == arf_crcascii)
 	{
 	  if (crc != file_hdr->c_chksum)
-	error (0, 0, _("%s: checksum error (0x%lx, should be 0x%lx)"),
+	error (0, 0, _("%s: checksum error (0x%x, should be 0x%x)"),
 		   file_hdr->c_name, crc, file_hdr->c_chksum);
 	}
   tape_skip_padding (in_file_des, file_hdr->c_filesize);
@@ -540,7 +540,7 @@ copyin_regular_file (struct cpio_file_stat* file_hdr, int in_file_des)
   if (archive_format == arf_crcascii)
 {
   if (crc != file_hdr->c_chksum)
-	error (0, 0, _("%s: checksum error (0x%lx, should be 0x%lx)"),
+	error (0, 0, _("%s: checksum error (0x%x, should be 0x%x)"),
 	   file_hdr->c_name, crc, file_hdr->c_chksum);
 }
 
@@ -1436,7 +1436,7 @@ process_copy_in ()
 	tape_skip_padding (in_file_des, file_hdr.c_filesize);
 	if (crc != file_hdr.c_chksum)
 	  {
-		error (0, 0, _("%s: checksum error (0x%lx, should be 0x%lx)"),
+		error (0, 0, _("%s: checksum error (0x%x, should be 0x%x)"),
 		   file_hdr.c_name, crc, file_hdr.c_chksum);
 	  }
  /* Debian hack: -v and -V now work with --only-verify-crc.
diff --git a/src/copyout.c b/src/copyout.c
index ab6a243..a5a8931 100644
--- a/src/copyout.c
+++ b/src/copyout.c
@@ -33,10 +33,10 @@
 /* Read FILE_SIZE bytes of FILE_NAME from IN_FILE_DES and
compute and return a checksum for them.  */
 
-static unsigned long
+static uint32_t
 read_for_checksum (int in_file_des, int file_size, char *file_name)
 {
-  unsigned long crc;
+  uint32_t crc;
   char buf[BUFSIZ];
   int bytes_left;
   int bytes_read;
diff --git a/src/cpiohdr.h b/src/cpiohdr.h
index 86ec988..9aa8ed9 100644
--- a/src/cpiohdr.h
+++ b/src/cpiohdr.h
@@ -123,7 +123,7 @@ struct cpio_file_stat /* Internal representation of a CPIO header */
   long c_rdev_maj;
   long c_rdev_min;
   size_t c_namesize;
-  unsigned long c_chksum;
+  uint32_t c_chksum;
   char *c_name;
   char *c_tar_linkname;
 };
diff --git a/src/extern.h b/src/extern.h
index be329ae..ef00242 100644
--- a/src/extern.h
+++ b/src/extern.h
@@ -75,7 +75,7 @@ extern char *new_media_message_after_number;
 extern int archive_des;
 extern char *archive_name;
 extern char *rsh_command_option;
-extern unsigned long crc;
+extern uint32_t crc;
 #ifdef DEBUG_CPIO
 extern int debug_flag;
 #endif
diff --git a/src/global.c b/src/global.c
index 29e7afc..e08e188 100644
--- a/src/global.c
+++ b/src/global.c
@@ -144,7 +144,7 @@ char *archive_name = NULL;
 char *rsh_command_option = NULL;
 
 /* CRC checksum.  */
-unsigned long crc;
+uint32_t crc;
 
 /* Input and output buffers.  */
 char *input_buffer, *output_buffer;
-- 
cgit v1.0-41-gc330



Bug#575267: cpio CRC checksum fixed upstream, not in Debian

2013-05-22 Thread appzer0

Hello,

CPIO is still not fixed in Debian (tested on sid). Checksum errors still 
occurs on cpio archives, amd64.


Upstream patch (applied on git but never released, as cpio 2.11 is 
pretty old) can be found there : 
http://git.gnu.org.ua/gitweb?p=cpio.git;a=commitdiff;h=refs/heads/master


Demo, first on a debian sid host, then in a chroot containing cpio with 
patch applied :


debian-ltop:/share/src/0linux/paquets/x86_64/base# cpio -i 
--only-verify-crc < gcc-4.7.3-x86_64-4.spack
cpio: files.xz: erreur sur la somme de contrôle (0x17026091c, devrait 
être 0x7026091c).

94683 blocs
debian-ltop:/share/src/0linux/paquets/x86_64/base# cd /0linux/
debian-ltop:/0linux# chroot ./
debian-ltop:/# cd share/src/0linux/paquets/x86_64/base/
debian-ltop:/share/src/0linux/paquets/x86_64/base# cpio -i 
--only-verify-crc < gcc-4.7.3-x86_64-4.spack

94683 blocs

*.spack are just cpio archives (package format for a homemade distro). 
The checksum error appears on relatively big archives. You may test 
those archives here (the biggest ones, like 'gcc' or 'linux') : 
http://ftp.igh.cnrs.fr/pub/os/linux/0linux/paquets/x86_64/base/


This bug is a blocker when cpio calls are embedded into scripts.

Thanks,


appzer0


--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org