if (! read_full_records)
{
- unsigned long rest = record_size - left;
+ idx_t rest = record_size - left;
FATAL_ERROR ((0, 0,
- ngettext ("Unaligned block (%lu byte) in archive",
- "Unaligned block (%lu bytes) in archive",
+ ngettext ("Unaligned block (%td byte) in archive",
+ "Unaligned block (%td bytes) in archive",
rest),
rest));
}
are always related, the second being BLOCKSIZE times the first. They do
not have _option in their name, even if their values is derived from
option decoding, as these are especially important in tar. */
-extern int blocking_factor;
-extern size_t record_size;
+extern idx_t blocking_factor;
+extern idx_t record_size;
extern bool absolute_names_option;
#include <rmt.h>
static union block *new_record;
-static int new_blocks;
+static idx_t new_blocks;
static bool acting_as_filter;
/* The number of records skipped at the start of the archive, when
/* Write the end of tape. FIXME: we can't use write_eot here,
as it gets confused when the input is at end of file. */
- int total_zero_blocks = 0;
+ idx_t total_zero_blocks = 0;
do
{
- int zero_blocks = blocking_factor - new_blocks;
+ idx_t zero_blocks = blocking_factor - new_blocks;
memset (new_record + new_blocks, 0, BLOCKSIZE * zero_blocks);
total_zero_blocks += zero_blocks;
write_record (total_zero_blocks < 2);
/* Child */
setenv ("TAR_VERSION", PACKAGE_VERSION, 1);
setenv ("TAR_ARCHIVE", *archive_name, 1);
- char intbuf[INT_BUFSIZE_BOUND (int)];
+ char intbuf[INT_BUFSIZE_BOUND (intmax_t)];
sprintf (intbuf, "%d", volume_number);
setenv ("TAR_VOLUME", intbuf, 1);
- sprintf (intbuf, "%d", blocking_factor);
+ sprintf (intbuf, "%jd", blocking_factor);
setenv ("TAR_BLOCKING_FACTOR", intbuf, 1);
setenv ("TAR_SUBCOMMAND", subcommand_string (subcommand_option), 1);
setenv ("TAR_FORMAT",
char intbuf[INT_BUFSIZE_BOUND (intmax_t)];
sprintf (intbuf, "%jd", checkpoint_number);
setenv ("TAR_CHECKPOINT", intbuf, 1);
- sprintf (intbuf, "%d", blocking_factor);
+ sprintf (intbuf, "%td", blocking_factor);
setenv ("TAR_BLOCKING_FACTOR", intbuf, 1);
setenv ("TAR_SUBCOMMAND", subcommand_string (subcommand_option), 1);
setenv ("TAR_FORMAT",
/* Define variables declared in common.h that belong to tar.c. */
enum subcommand subcommand_option;
enum archive_format archive_format;
-int blocking_factor;
-size_t record_size;
+idx_t blocking_factor;
+idx_t record_size;
bool absolute_names_option;
bool utc_option;
bool full_time_option;
if (! (xstrtoumax (arg, 0, 10, &u, "") == LONGINT_OK
&& !ckd_add (&blocking_factor, u, 0)
&& 0 < blocking_factor
- && !ckd_mul (&record_size, u, BLOCKSIZE)))
+ && !ckd_mul (&record_size, u, BLOCKSIZE)
+ && record_size <= min (SSIZE_MAX, SIZE_MAX)))
USAGE_ERROR ((0, 0, "%s: %s", quotearg_colon (arg),
_("Invalid blocking factor")));
}
uintmax_t u;
if (! (xstrtoumax (arg, NULL, 10, &u, TAR_SIZE_SUFFIXES) == LONGINT_OK
- && !ckd_add (&record_size, u, 0)))
+ && !ckd_add (&record_size, u, 0)
+ && record_size <= min (SSIZE_MAX, SIZE_MAX)))
USAGE_ERROR ((0, 0, "%s: %s", quotearg_colon (arg),
_("Invalid record size")));
if (record_size % BLOCKSIZE != 0)