struct stat current_stat; /* stat struct corresponding */
enum archive_format current_format; /* recognized format */
-static char const *tartime PARAMS ((time_t));
static uintmax_t from_header PARAMS ((const char *, size_t, const char *,
uintmax_t, uintmax_t));
switch (prev_status)
{
case HEADER_STILL_UNREAD:
- WARN ((0, 0, _("This does not look like a tar archive")));
+ ERROR ((0, 0, _("This does not look like a tar archive")));
/* Fall through. */
case HEADER_ZERO_BLOCK:
case HEADER_SUCCESS:
- WARN ((0, 0, _("Skipping to next header")));
+ ERROR ((0, 0, _("Skipping to next header")));
break;
case HEADER_END_OF_FILE:
written = available_space_after (data_block);
if (written > size)
written = size;
- errno = 0; /* FIXME: errno should be read-only */
+ errno = 0;
check = fwrite (data_block->buffer, sizeof (char), written, stdlis);
set_next_block_after ((union block *)
(data_block->buffer + written - 1));
}
/* Parse the output of older, unportable tars, which generate
- negative values in two's complement octal. */
- if ((overflow || maxval < value) && '4' <= *where1)
+ negative values in two's complement octal. If the leading
+ nonzero digit is 1, we can't recover the original value
+ reliably; so do this only if the digit is 2 or more. This
+ catches the common case of 32-bit negative time stamps. */
+ if ((overflow || maxval < value) && '2' <= *where1)
{
/* Compute the negative of the input value, assuming two's
complement. */
- for (value = 0, where = where1, overflow = 0; ; )
+ int digit = (*where1 - '0') | 4;
+ overflow = 0;
+ value = 0;
+ where = where1;
+ for (;;)
{
- value += 7 - (*where++ - '0');
+ value += 7 - digit;
+ where++;
if (where == lim || ! ISODIGIT (*where))
break;
+ digit = *where - '0';
overflow |= value ^ (value << LG_8 >> LG_8);
value <<= LG_8;
}
/* Return a printable representation of T. The result points to
static storage that can be reused in the next call to this
function, to ctime, or to asctime. */
-static char const *
+char const *
tartime (time_t t)
{
static char buffer[max (UINTMAX_STRSIZE_BOUND + 1,