From 20b617a8aba25d244705137bfc8882224b0a9567 Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Sun, 1 Sep 2024 12:32:59 +0300 Subject: [PATCH] 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 --- src/vfs/tar/tar-internal.h | 4 ++-- src/vfs/tar/tar-xheader.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/vfs/tar/tar-internal.h b/src/vfs/tar/tar-internal.h index 0ce75afd8..b9abab377 100644 --- a/src/vfs/tar/tar-internal.h +++ b/src/vfs/tar/tar-internal.h @@ -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 */ diff --git a/src/vfs/tar/tar-xheader.c b/src/vfs/tar/tar-xheader.c index 41fc02828..ce70c26c2 100644 --- a/src/vfs/tar/tar-xheader.c +++ b/src/vfs/tar/tar-xheader.c @@ -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;