Bug 171649 - cpio: checksum error on 64-bit machines
cpio: checksum error on 64-bit machines
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: cpio (Show other bugs)
4.0
x86_64 Linux
medium Severity medium
: ---
: ---
Assigned To: Peter Vrabec
Brock Organ
:
Depends On:
Blocks: 187538
  Show dependency treegraph
 
Reported: 2005-10-24 15:01 EDT by Jim Castleberry
Modified: 2007-11-30 17:07 EST (History)
0 users

See Also:
Fixed In Version: RHBA-2006-0305
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2006-04-19 15:00:08 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Patch for vanilla cpio 2.6 (531 bytes, patch)
2005-10-24 15:03 EDT, Jim Castleberry
no flags Details | Diff
my patch fixing this bug (1.20 KB, patch)
2005-10-26 06:59 EDT, Peter Vrabec
no flags Details | Diff

  None (edit)
Description Jim Castleberry 2005-10-24 15:01:37 EDT
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12) Gecko/20050915

Description of problem:
Package: cpio
Version: 2.6-7

[ The above pseudo-headers are for the Debian email bug reporting system. ]

Vanilla cpio 2.6 sometimes writes bad crcs in the cpio header on 64-bit machines.  It seems to
show up only on some large files.  The symptom is that the crc stored in the file appears to
be shifted by one nibble, and fails the crc check on copy-out.

For example using the Openoffice 2.0 release from openoffice.org mirrors, eg
    http://mirrors.ibiblio.org/pub/mirrors/openoffice/stable/2.0.0/OOo_2.0.0_LinuxIntel_install.tar.gz

  $ uname -a Linux centos 2.6.9-11.ELsmp #1 SMP Wed Jun 8 16:59:12 CDT 2005 x86_64 x86_64 x86_64 GNU/Linux
  $ cpio --version cpio (GNU cpio) 2.6
  $ echo OOo_2.0.0_LinuxIntel_install.tar.gz |cpio -o --format=crc >test.cpio
  207906 blocks
  $ cpio -i --only-verify-crc <test.cpio
  cpio: OOo_2.0.0_LinuxIntel_install.tar.gz: checksum error (0x32bf3b47, should be 0x332bf3b4)
  207906 blocks
  $

Doing the same thing on a 32-bit i386 machine running the same software works properly.
The only differences in the output file are in the c_maj, m_min, and c_chksum fields of
the cpio header.  All the other fields and the file data are the same and correct.

The cpio-2.5 that comes with the current Redhat EL (cpio-2.5-8.RHEL4) exhibits the
identical problem.

The bug was reported to Redhat by Michael J. Donahue in 1998 in cpio 2.4.2 on Redhat 4.1
for alpha:
    http://www.redhat.com/archives/axp-list/1998-March/msg00494.html
but apparently never addressed.

It was rediscovered by Tom Vier in 2001 2.4.2 on Debian and fixed by the debian folks:
    http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=100456
Looking at their patches for 2.4.2 at
    http://ftp.debian.org/pool/main/c/cpio/cpio_2.4.2-39woody1.diff.gz
the fix was in function write_out_header():
  @@ -60,7 +61,7 @@
   	       file_hdr->c_gid, file_hdr->c_nlink, file_hdr->c_mtime,
   	     file_hdr->c_filesize, file_hdr->c_dev_maj, file_hdr->c_dev_min,
   	   file_hdr->c_rdev_maj, file_hdr->c_rdev_min, file_hdr->c_namesize,
  -	       file_hdr->c_chksum);
  +	       file_hdr->c_chksum & 0xffffffff);
         tape_buffered_write (ascii_header, out_des, 110L);
   
         /* Write file name to output.  */

I applied that same change to the vanilla 2.6 copyout.c and it fixes the problem.
Patch is attached.

Note 1: The current Redhat ships cpio 2.5 with this defect.
Note 2: Debian carried the patch over to their patches for cpio 2.5 but seems to have
        dropped it from their patches for 2.6.  So I'd guess that their 2.6 has the same problem
        too, though I haven't tried it.


Version-Release number of selected component (if applicable):
cpio-2.5-8.RHEL4

How reproducible:
Always

Steps to Reproduce:
1. echo OOo_2.0.0_LinuxIntel_install.tar.gz |cpio -o --format=crc >test.cpio
2. cpio -i --only-verify-crc <test.cpio
3.
  

Actual Results:  cpio: OOo_2.0.0_LinuxIntel_install.tar.gz: checksum error (0x32bf3b47, should be 0x332bf3b4)
207906 blocks

Expected Results:  207906 blocks

Additional info:
Comment 1 Jim Castleberry 2005-10-24 15:03:08 EDT
Created attachment 120316 [details]
Patch for vanilla cpio 2.6
Comment 2 Peter Vrabec 2005-10-26 06:55:36 EDT
Your patch did not help me. Problem still persists.

cpio: OOo_2.0.0_LinuxIntel_install.tar.gz: checksum error (0x332bf3b47, should
be 0x32bf3b47)

It's because:
copyin.c:1585  
  if (crc != file_hdr.c_chksum)
crc is unsigned long and file_hdr.c_chksum is truncated by your patch.
Comment 3 Peter Vrabec 2005-10-26 06:59:11 EDT
Created attachment 120403 [details]
my patch fixing this bug
Comment 4 Jim Castleberry 2005-10-26 11:02:41 EDT
Peter, you're right.  My patch was incomplete.  Thanks.
Comment 13 Red Hat Bugzilla 2006-04-19 15:00:08 EDT
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on the solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2006-0305.html

Note You need to log in before you can comment on or make changes to this bug.