(blocking_factor, record_size): change type.

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" calls behave sensibly.

Sync with GNU tar 3ffe2eb0738504aabee0d3b4d0c03e01739b9d6c.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2024-09-01 12:54:11 +03:00
parent ebbff2266a
commit 465d8b962a
2 changed files with 5 additions and 4 deletions

View File

@ -13,6 +13,7 @@
#include "lib/stdckdint.h"
#endif
#include "lib/idx.h"
#include "lib/vfs/xdirentry.h" /* vfs_s_super */
/*** typedefs(not structures) and defined constants **********************************************/
@ -289,8 +290,8 @@ struct tar_stat_info
/*** global variables defined in .c file *********************************************************/
extern const int blocking_factor;
extern const size_t record_size;
extern const idx_t blocking_factor;
extern const idx_t record_size;
extern union block *record_end; /* last+1 block of archive record */
extern union block *current_block; /* current block of archive */

View File

@ -59,8 +59,8 @@
/* Size of each record, once in blocks, once in bytes. Those two variables are always related,
the second being BLOCKSIZE times the first. */
const int blocking_factor = DEFAULT_BLOCKING;
const size_t record_size = DEFAULT_BLOCKING * BLOCKSIZE;
const idx_t blocking_factor = DEFAULT_BLOCKING;
const idx_t record_size = DEFAULT_BLOCKING * BLOCKSIZE;
/* As we open one archive at a time, it is safe to have these static */
union block *record_end; /* last+1 block of archive record */