mirror of
https://git.savannah.gnu.org/git/tar.git
synced 2026-08-18 07:17:20 +00:00
Handle enormous record sizes better
Formerly the code could misbehave when the user specified a record size greater than min (INT_MAX * 512 + 511, PTRDIFF_MAX, SSIZE_MAX). * src/delete.c (new_blocks, delete_archive_members): * src/system.c (sys_exec_info_script): * src/tar.c (blocking_factor, record_size): Don’t limit blocking factor to INT_MAX. Prefer signed type for record_size. Do not exceed IDX_MAX or SSIZE_MAX for record_size; the SSIZE_MAX limit is needed so that ‘read’ and ‘write’ calls behave sensibly.
This commit is contained in:
+3
-3
@@ -23,7 +23,7 @@
|
||||
#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
|
||||
@@ -363,11 +363,11 @@ delete_archive_members (void)
|
||||
/* 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);
|
||||
|
||||
Reference in New Issue
Block a user