Reduce variable scope. Get rid of extra NULL check: g_strdup() handles
NULL correctly. Remove intermediate variable.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Simplify the code by assuming C99 initializers.
* (base_64_digits): Remove; no longer needed.
* (base64_map): Now a constant. Initialized statically,
and with invalid entries being 0 not 64, and with valid
entries being 1 greater than before.
* (tar_base64_init): Remove; only use removed.
* (tar_from_header): Adjust to new values in base64_map.
Sync with GNU tar 43231ae554d0dacbcc32e2d0fe574c9d0e183258.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
* (tar_checksum): recode to avoid casts.
* (tar_from_header): likewise.
Sync with GNU tar 1521d3dae01f91606c639eb745ea565ef723e38d.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
When parsing numbers prefer using strtosysint() (renamed stoint)
to using strtoul() and its variants.
This is simpler and faster and likely more reliable than
relying on quirks of the system strtoul() etc,
and it standardizes how tar deals with parsing integers.
Among other things, the C standard and POSIX don't specify
what strtol() does to errno when conversions cannot be performed,
and it requires strtoul() to support "-" before unsigned numbers.
* (stoint): rename from strtosysint, move to tar-internal.c and add
a gboollean * argument for reporting overflow. All callers changed.
* (decode_num): prefer stoint() to strtol() etc. Don't rely on
errno == EINVAL as the standards don't guarantee it.
* (decode_signed_num): likewise.
* (decode_record): likewise.
* (sparse_map_decoder): likewise.
* (decode_timespec): Simplify by using ckd_sub() rather than checking
for overflow by hand.
* tar-sparse.c: remove include of errno.h, it's no lomger used.
* tar-xheader.c: likewise
Sync with GNU tar d1e72a536f26188230a147d948b9057714fd0b6b.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
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 shouldn't affect behavior; it's just a cleanup.
Sync with GNU tar eb9bb9bf8049522230a0654c3f32e6373b945254.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
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>
Use UINTMAX_WIDTH rather than computing it by hand.
Sync with GNU tar fbc60c2334326fc2f748226abe76190ecf39a26b.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
* (oldgnu_add_sparse): prefer ckd_add and ckd_mul to the intprops.h
equivalents, since stdckdint.h is now standard.
* (pax_decode_header): likewise.
Remove macros defined in lib/intprops-internal.h.
Sync with GNU tar a9372cf08a05723b2a06efff3402077598138238.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Use ckd_add instead of doing overflow checking by hand.
Although the old code was correct on all practical hosts,
the new code is simpler and works even on weird hosts
where SIZE_MAX <= INT_MAX.
Sync with GNU tar 8a3fc529729acf38276b27f6b7bc50962dfab799.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Prefer ckd_add() to doing overflow checking by hand.
Sync with GNU tar 927d67855e2e83b6b06eb9095f65e4e695d6af7e.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
* (file_progress_show_deleting): take 'vfs_path_t *' instead of 'char *'.
* (try_erase_dir): likewise.
* (erase_file): sync with new file_progress_show_deleting().
* (recursive_erase): sync with new file_progress_show_deleting() and
try_erase_dir().
* (erase_dir_iff_empty): likewise.
* (erase_dir): likewise.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Sync with gnulib 64ddc975e72cb55d2b2d755c25603bd70312aa5e:
This patch alters xstrtoumax behavior slightly, in areas are not
likely to affect any real callers, by making xstrtoumax behave more
like the system strtol. In particular, it lets xstrtoumax support
bases other than those required by POSIX, if the underlying
implementation does; this removes the need for an g_assert().
* lib/strutil/strtol.c: Do not include stdio.h.
(xstrtoumax): Use same parameter names as POSIX, to make it
easier for outsiders to follow. Do not require the base to be 0-36,
as the underlying implementation is allowed to support other bases.
Sync with gnulib 16b33e6649425fcdce095f262da98b539d2f7448.
* (xstrtoumax): Don't update *endptr if strtol doesn't.
Also, if the underlying strtol gives an unusual error number and
sets *endpnr = nptr, assume that's an error not a missing number.
Sync with gnulib bd1e981434c98751b1106a1744e77a27317b52b3
* (xstrtoumax): Stop worrying about hypothetical implementations that
are causing more confusion than the code is worth. Instead, go back
more to old way of doing things. None of this matters for practical
applications.
Add commemt.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>