Article View: gnu.utils.bug
Article #809GNU tar header checksum bug
From: Robert E. Brown
Date: Thu, 10 Sep 1992 19:55
Date: Thu, 10 Sep 1992 19:55
80 lines
2537 bytes
2537 bytes
This bug report is for GNU tar versions 1.10 and 1.11.
Different versions of tar seem to compute header checksums differently. I
suspect that the original tar code added up a bunch of "char" values, which
were unsigned on the PDP-11 and that the code was never changed when signed
chars were introduced. The following patch causes GNU tar to be a little more
forgiving when it tries to read tar archives created with /bin/tar on Nexts,
Suns, and others.
*** list.c.~1~ Tue Sep 8 16:22:38 1992
--- list.c Thu Sep 10 15:47:56 1992
***************
*** 289,295 ****
read_header()
{
register int i;
! register long sum, recsum;
register char *p;
register union record *header;
long from_oct();
--- 289,295 ----
read_header()
{
register int i;
! register long sum, signed_sum, recsum;
register char *p;
register union record *header;
long from_oct();
***************
*** 314,326 ****
* We can't use unsigned char here because of old compilers,
* e.g. V7.
*/
sum += 0xFF & *p++;
}
/* Adjust checksum to count the "chksum" field as blanks. */
for (i = sizeof(header->header.chksum); --i >= 0;)
sum -= 0xFF & header->header.chksum[i];
! sum += ' '* sizeof header->header.chksum;
if (sum == 8*' ') {
/*
--- 314,331 ----
* We can't use unsigned char here because of old compilers,
* e.g. V7.
*/
+ signed_sum += *p;
sum += 0xFF & *p++;
}
/* Adjust checksum to count the "chksum" field as blanks. */
for (i = sizeof(header->header.chksum); --i >= 0;)
+ {
sum -= 0xFF & header->header.chksum[i];
! signed_sum -= (char) header->header.chksum[i];
! }
! sum += ' ' * sizeof header->header.chksum;
! signed_sum += ' ' * sizeof header->header.chksum;
if (sum == 8*' ') {
/*
***************
*** 330,336 ****
return 2;
}
! if (sum != recsum)
return 0;
/*
--- 335,341 ----
return 2;
}
! if (sum != recsum && signed_sum != recsum)
return 0;
/*
Technical Details
Message-ID:
<9209101955.AA01189@_grettir.quorum.com_>Path:
arc1-ca.pugleaf.net!sparky!uunet!spool.mu.edu!sdd.hp.com!usc!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!quorum.COM!brownShow Full Headers
Complete Article Headers
Newsgroups: gnu.utils.bug Path: arc1-ca.pugleaf.net!sparky!uunet!spool.mu.edu!sdd.hp.com!usc!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!quorum.COM!brown From: brown@quorum.COM (Robert E. Brown) Subject: GNU tar header checksum bug Message-ID: <9209101955.AA01189@_grettir.quorum.com_> Sender: gnulists@ai.mit.edu Organization: GNUs Not Usenet Distribution: gnu Date: Thu, 10 Sep 1992 19:55:26 GMT Approved: bug-gnu-utils@prep.ai.mit.edu Lines: 81