tar: avoid strtoul().

This is part of the general trend to prefer signed integer types,
to allow better runtime checking with -fsanitize=undefined etc.

  * (struct tar_stat_info): ue intmax_t, not unsigned, for sparse major
    and minor.
  * (tar_sparse_major): likewise.
  * (tar_sparse_minor): likewise.

Sync with GNU tar 4642cd04edbd57414e004920fa4976d9f3be6206.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2024-09-01 12:32:59 +03:00
parent 79b10fc8a7
commit 20b617a8ab
2 changed files with 4 additions and 4 deletions

View File

@ -268,8 +268,8 @@ struct tar_stat_info
gboolean is_sparse; /**< is the file sparse */
/* For sparse files */
unsigned int sparse_major;
unsigned int sparse_minor;
intmax_t sparse_major;
intmax_t sparse_minor;
GArray *sparse_map; /**< array of struct sp_array */
off_t real_size; /**< real size of sparse file */

View File

@ -772,7 +772,7 @@ sparse_major_decoder (struct tar_stat_info *st, const char *keyword, const char
(void) size;
if (!decode_num (&u, arg, TYPE_MAXIMUM (unsigned), keyword))
if (!decode_num (&u, arg, INTMAX_MAX, keyword))
return FALSE;
st->sparse_major = u;
@ -788,7 +788,7 @@ sparse_minor_decoder (struct tar_stat_info *st, const char *keyword, const char
(void) size;
if (!decode_num (&u, arg, TYPE_MAXIMUM (unsigned), keyword))
if (!decode_num (&u, arg, INTMAX_MAX, keyword))
return FALSE;
st->sparse_minor = u;