Thread View: gnu.utils.bug
1 messages
1 total messages
Started by Robert E. Brown
Thu, 10 Sep 1992 19:55
GNU tar header checksum bug
Author: 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;
/*
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads