- for (size = current_stat_info.stat.st_size; size > 0; size -= written)
- {
- if (multi_volume_option)
- save_sizeleft = size;
- data_block = find_next_block ();
- if (!data_block)
- {
- ERROR ((0, 0, _("Unexpected EOF in archive")));
- break; /* FIXME: What happens, then? */
- }
- written = available_space_after (data_block);
- if (written > size)
- written = size;
- errno = 0;
- check = fwrite (data_block->buffer, sizeof (char), written, stdlis);
- set_next_block_after ((union block *)
- (data_block->buffer + written - 1));
- if (check != written)
- {
- write_error_details (current_stat_info.file_name, check, written);
- skip_file (size - written);
- break;
- }
- }
- if (multi_volume_option)
- assign_string (&save_name, 0);
- fputc ('\n', stdlis);
- fflush (stdlis);
- return;
+ }
+
+ skip_member ();
+}
+
+/* Check header checksum */
+/* The standard BSD tar sources create the checksum by adding up the
+ bytes in the header as type char. I think the type char was unsigned
+ on the PDP-11, but it's signed on the Next and Sun. It looks like the
+ sources to BSD tar were never changed to compute the checksum
+ correctly, so both the Sun and Next add the bytes of the header as
+ signed chars. This doesn't cause a problem until you get a file with
+ a name containing characters with the high bit set. So tar_checksum
+ computes two checksums -- signed and unsigned. */
+
+enum read_header
+tar_checksum (union block *header, bool silent)
+{
+ size_t i;
+ int unsigned_sum = 0; /* the POSIX one :-) */
+ int signed_sum = 0; /* the Sun one :-( */
+ int recorded_sum;
+ uintmax_t parsed_sum;
+ char *p;
+
+ p = header->buffer;
+ for (i = sizeof *header; i-- != 0;)
+ {
+ unsigned_sum += (unsigned char) *p;
+ signed_sum += (signed char) (*p++);
+ }
+
+ if (unsigned_sum == 0)
+ return HEADER_ZERO_BLOCK;