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:
Paul Eggert
2024-08-08 10:51:39 -07:00
parent eb9bb9bf80
commit 3ffe2eb073
5 changed files with 17 additions and 15 deletions

View File

@@ -985,11 +985,11 @@ short_read (size_t status)
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));
}