]> git.ipfire.org Git - thirdparty/tar.git/log
thirdparty/tar.git
12 months agoParse level options more reliably
Paul Eggert [Sat, 3 Aug 2024 06:33:50 +0000 (23:33 -0700)] 
Parse level options more reliably

* src/tar.c (parse_opt): Don’t mishandle out-of-range LEVEL_OPTION.

12 months agoMinor utf8.c improvements
Paul Eggert [Sat, 3 Aug 2024 06:32:42 +0000 (23:32 -0700)] 
Minor utf8.c improvements

* src/utf8.c: Minor rephrases for -1.

12 months agoSimplify ST_DEV_MSB
Paul Eggert [Sat, 3 Aug 2024 06:30:42 +0000 (23:30 -0700)] 
Simplify ST_DEV_MSB

* src/incremen.c (ST_DEV_MSB):
Use TYPE_WIDTH rather than computing it by hand.

12 months agoUse ckd_mul, ckd_add in to_octal, to_base256
Paul Eggert [Sat, 3 Aug 2024 06:29:56 +0000 (23:29 -0700)] 
Use ckd_mul, ckd_add in to_octal, to_base256

* src/create.c (to_octal, to_base256): Simplify.

12 months agoUse ckd_mul, ckd_add in from_header
Paul Eggert [Sat, 3 Aug 2024 05:13:20 +0000 (22:13 -0700)] 
Use ckd_mul, ckd_add in from_header

* src/common.h (LG_64): Remove; no longer used.
* src/list.c (from_header):
Use ckd_mul, ckd_add rather than doing it by hand.

12 months agoPrefer < 0 to == -1 where either will do
Paul Eggert [Sat, 3 Aug 2024 05:11:13 +0000 (22:11 -0700)] 
Prefer < 0 to == -1 where either will do

Also, fix an unlikely read overflow in sys_exec_setmtime_script.
* src/buffer.c (open_compressed_archive):
* src/compare.c (verify_volume):
* src/exclist.c (info_attach_exclist):
* src/misc.c (xfork):
* src/sparse.c (sparse_scan_file_seek):
* src/system.c (sys_wait_for_child, sys_spawn_shell)
(wait_for_grandchild, sys_wait_command, sys_exec_info_script)
(sys_exec_checkpoint_script, sys_exec_setmtime_script):
* src/transform.c (_single_transform_name_to_obstack):
* src/xattrs.c (xattrs__acls_set, xattrs_acls_get)
(xattrs_xattrs_get, xattrs__fd_set, xattrs_selinux_get)
(xattrs_selinux_set):
* tests/checkseekhole.c (check_seek_hole, main):
Simplify failure tests by just looking at return value sign.
* src/system.c (sys_exec_setmtime_script):
Don’t assume ‘read’ result fits in int.
(sys_exec_setmtime_script): Don’t reject 1 second before Epoch.

12 months agoxsparse dry runs should not create output
Paul Eggert [Sat, 3 Aug 2024 04:58:53 +0000 (21:58 -0700)] 
xsparse dry runs should not create output

* scripts/xsparse.c (expand_sparse, main): Check for syscall
failure.  Do not create output file if a dry run.

12 months agoBetter xsparse outname guessing
Paul Eggert [Fri, 2 Aug 2024 18:23:23 +0000 (11:23 -0700)] 
Better xsparse outname guessing

* scripts/xsparse.c (guess_outname): Use simpler algorithm,
that doesn’t mishandle outnames like ‘/foo’.

12 months agoUse xalignalloc
Paul Eggert [Fri, 2 Aug 2024 16:32:11 +0000 (09:32 -0700)] 
Use xalignalloc

It ports around issues that our handwritten code does not.
* gnulib.modules: Add xalignalloc.
* src/misc.c (ptr_align, page_aligned_alloc): Remove.
All page_aligned_alloc callers changed to use xalignalloc.

12 months agoMake stripped_prefix_len signed
Paul Eggert [Fri, 2 Aug 2024 16:07:06 +0000 (09:07 -0700)] 
Make stripped_prefix_len signed

This is part of the general guideline that signed integer types
are safer.
* src/names.c (stripped_prefix_len): Return ptrdiff_t,
not size_t.  All callers changed.

12 months agofrom_header minor width cleanup
Paul Eggert [Fri, 2 Aug 2024 07:29:07 +0000 (00:29 -0700)] 
from_header minor width cleanup

* src/list.c (from_header): Use UINTMAX_WIDTH rather than
computing it by hand.

12 months agoDon’t assume mode_t fits in unsigned long
Paul Eggert [Fri, 2 Aug 2024 07:27:40 +0000 (00:27 -0700)] 
Don’t assume mode_t fits in unsigned long

* src/system.c (oct_to_env): Don’t assume mode_t fits in unsigned
long.  Do not output excess leading 1 bits.  When the mode is
zero, generate "0" rather than "00".  Use sprintf instead of
snprintf, since the output won’t be truncated; in general we don’t
use snprintf unless we want output to be truncated and truncation
is typically not GNU style.

12 months agoPrefer C99 formats like %jd to doing it by hand
Paul Eggert [Fri, 2 Aug 2024 02:31:50 +0000 (19:31 -0700)] 
Prefer C99 formats like %jd to doing it by hand

It’s now safe to assume support for C99 formats like %jd, so remove
some of the longwinded formatting code put in only to be portable to
pre-C99 platforms.
* gnulib.modules: Add intprops.
* src/buffer.c (format_total_stats, try_new_volume)
(write_volume_label):
* src/checkpoint.c (format_checkpoint_string):
* src/compare.c (verify_volume):
* src/create.c (to_chars_subst, dump_regular_file):
* src/incremen.c (read_num):
* src/list.c (read_and, from_header, simple_print_header)
(print_for_mkdir):
* src/sparse.c (sparse_dump_region):
* src/system.c (dec_to_env, sys_exec_info_script)
(sys_exec_checkpoint_script):
* src/xheader.c (out_of_range_header):
Prefer C99 formats like %jd and %ju to STRINGIFY_BIGINT.
* src/common.h: Sort includes.
Include intprops.h, verify.h.  All other includes of verify.h
removed.
(intmax, uintmax): New functions and macros.
(STRINGIFY_BIGINT): Remove; no longer used.
(TIMESPEC_STRSIZE_BOUND): Make it 1 byte bigger, for negatives.
* src/create.c (MAX_VAL_WITH_DIGITS, to_base256):
Use *_WIDTH macros rather than assuming no padding bits.
Prefer UINTMAX_MAX to (uintmax_t) -1.
* src/list.c (tartime): Use strftime result rather
than running strlen later.
* src/misc.c (timetostr): New function.  Prefer it when
printing time_t values.

12 months agoFix unlikely problems with time overflow
Paul Eggert [Thu, 1 Aug 2024 17:02:06 +0000 (10:02 -0700)] 
Fix unlikely problems with time overflow

Also, fix some rounding errors while we’re in the neighborhood.
* src/buffer.c (duration_ns, compute_duration_ns): Rename from
‘duration’ and ‘compute_duration’, and count ns rather than s, to
lessen rounding error.  All uses changed.
(compute_duration_ns): Work even if the clock moves backward
and time_t is unsigned.
(print_stats): Don’t worry about null or empty TEXT, as that
cannot happen.  Compare double to UINTMAX_MAX + 1.0, not
to UINTMAX_MAX, so that the comparison is exact.
Handle the unlikely case that numbytes >= UINTMAX_MAX.
* src/tar.c (parse_opt): Treat -L hugenumber as effectively
infinity rather than erroring out.
Prefer ckd_add to checking overflow by hand.

12 months agomaint: omit space between "*" and "p"
Paul Eggert [Thu, 1 Aug 2024 14:17:32 +0000 (07:17 -0700)] 
maint: omit space between "*" and "p"

12 months agoptrdiff_t, not int
Paul Eggert [Thu, 1 Aug 2024 14:16:49 +0000 (07:16 -0700)] 
ptrdiff_t, not int

* src/delete.c (delete_archive_members): Use ptrdiff_t, not int,
to count memory blocks.
(write_recent_bytes): Simplify remainder calculation.

12 months agoptrdiff_t, not ssize_t
Paul Eggert [Thu, 1 Aug 2024 14:15:01 +0000 (07:15 -0700)] 
ptrdiff_t, not ssize_t

* src/buffer.c (bufmap_reset, _flush_write):
Use ptrdiff_t, not ssize_t, to record pointer differences.
POSIX allows systems where size_t is 64 bits but ssize_t is only 32;
Ultrix used to do that, though no current systems do.

12 months agoPrefer stdckdint.h to intprops.h
Paul Eggert [Wed, 31 Jul 2024 00:59:04 +0000 (17:59 -0700)] 
Prefer stdckdint.h to intprops.h

Problem reported by Collin Funk in:
https://lists.gnu.org/r/bug-tar/2024-07/msg00000.html
though this patch is more general than Collin’s suggestion.
* src/compare.c (diff_multivol):
* src/delete.c (move_archive):
* src/sparse.c (oldgnu_add_sparse, pax_decode_header):
* src/system.c (mtioseek):
Prefer ckd_add and ckd_mul to the intprops.h equivalents,
since stdckdint.h is now standard.

12 months agoUse ckd_add in page_aligned_alloc
Paul Eggert [Wed, 31 Jul 2024 00:55:31 +0000 (17:55 -0700)] 
Use ckd_add in page_aligned_alloc

* src/misc.c (page_aligned_alloc): Use ckd_add
instead of doing overflow checking by hand.

12 months agoSimplify read_header overflow checking
Paul Eggert [Wed, 31 Jul 2024 00:47:10 +0000 (17:47 -0700)] 
Simplify read_header overflow checking

* src/list.c (read_header): 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.

12 months agoCleaner overflow checking in xheader_read
Paul Eggert [Tue, 30 Jul 2024 23:21:39 +0000 (16:21 -0700)] 
Cleaner overflow checking in xheader_read

* src/xheader.c (xheader_read): Prefer ckd_add to
doing overflow checking by hand.

12 months agomaint: use static_assert
Paul Eggert [Tue, 30 Jul 2024 23:19:35 +0000 (16:19 -0700)] 
maint: use static_assert

* gnulib.modules: Add assert-h, for static_assert.
* src/common.h, src/list.c, src/misc.c:
Prefer static_assert to #if + #error.  This doesn’t fix any bugs; it’s
just that in general it’s better to avoid the preprocessor.

12 months agoFix tests/ckmtime.c arithmetic
Paul Eggert [Tue, 30 Jul 2024 15:35:59 +0000 (08:35 -0700)] 
Fix tests/ckmtime.c arithmetic

* tests/ckmtime.c (main): Don’t assume time_t is signed.
Avoid integer overflows (quite possible if time_t is 32 bit).
Do calculations precisely, without any rounding errors.

12 months agoFix unlikely overflow in utf8_convert
Paul Eggert [Tue, 30 Jul 2024 15:33:39 +0000 (08:33 -0700)] 
Fix unlikely overflow in utf8_convert

* src/utf8.c (utf8_convert): Check for integer overflow.

12 months agoFix unlikely overflow in transform.c
Paul Eggert [Tue, 30 Jul 2024 15:32:55 +0000 (08:32 -0700)] 
Fix unlikely overflow in transform.c

* src/transform.c (_single_transform_name_to_obstack):
Use xinmalloc to check for integer overflow.

12 months agoBetter overflow checking for blocking factor
Paul Eggert [Tue, 30 Jul 2024 15:31:45 +0000 (08:31 -0700)] 
Better overflow checking for blocking factor

* src/tar.c (parse_opt): Use ckd_add and ckd_mul instead of
less-obvious code that relies on implementation-defined
conversions.

12 months agoxsparse cleanup, including integer overflow
Paul Eggert [Tue, 30 Jul 2024 03:56:27 +0000 (20:56 -0700)] 
xsparse cleanup, including integer overflow

* scripts/xsparse.c: Include inttypes.h, for strtoimax.
Don’t include stdint.h, since inttypes.h includes it.
Sort include directives.
Make all extern functions and vars static, except for ‘main’.
(string_to_off): Use strtoimax instead of doing overflow
checking by hand, incorrectly (it relied on undefined behavior).
(string_to_size): New arg MAXSIZE.  All callers changed.
(get_var): Return bool not int.  Fix unlikely integer overflow.
Use strncmp instead of memcmp, to avoid unlikely pointer overflow.
(read_xheader, read_map, main): Avoid unlikely integer overflow.
Check for I/O errors more consistently.
(main): Prefer bool to int, and put vars near use.

12 months agomaint: fix some unlikely wordsplit overflows
Paul Eggert [Mon, 29 Jul 2024 22:36:47 +0000 (15:36 -0700)] 
maint: fix some unlikely wordsplit overflows

* gnulib.modules: Add reallocarray.
* lib/wordsplit.c: Include stdckdint.h.
(ISDELIM, expvar, isglob, scan_word):
Defend against strchr (s, 0) always succeeding.
(alloc_space, wsplit_assign_vars):
Fix some unlikely integer overflows, partly by using reallocarray.
(alloc_space): Avoid quadratic worst-case behavior.
(isglob): Return bool, not int.  Accept size_t, not int.
(to_num): Remove; no longer used.
(xtonum): Clarify the code the bit.  Rely on portable
conversion to unsigned char rather than problematic pointer cast.

12 months agomaint: prefer C23 if available
Paul Eggert [Sun, 28 Jul 2024 20:51:45 +0000 (13:51 -0700)] 
maint: prefer C23 if available

* gnulib.modules: Add std-gnu23.

12 months agoAdd some gnulib.modules
Paul Eggert [Sun, 28 Jul 2024 20:50:37 +0000 (13:50 -0700)] 
Add some gnulib.modules

* gnulib.modules: Add errno, limits-h, safe-read, sys_stat.
Not sure about the relationship between gnulib.modules
and paxutils/gnulib.modules, but anyway tar itself uses
these so we should depend on them.  (Perhaps it would be
better if there was just one Gnulib module list for tar;
that would be less confusing.)

12 months agobuild: update gnulib and paxutils submodules to latest
Paul Eggert [Sun, 28 Jul 2024 00:59:59 +0000 (17:59 -0700)] 
build: update gnulib and paxutils submodules to latest

12 months agoPacify gcc 14 -Wanalyzer-null-argument
Paul Eggert [Sat, 27 Jul 2024 07:26:15 +0000 (00:26 -0700)] 
Pacify gcc 14 -Wanalyzer-null-argument

* src/tar.c (optloc_eq): Add another ‘assume’.

12 months agoPacify gcc 14 -Wanalyzer-infinite-loop
Paul Eggert [Sat, 27 Jul 2024 07:05:49 +0000 (00:05 -0700)] 
Pacify gcc 14 -Wanalyzer-infinite-loop

* gnulib.modules: Add stddef, for ‘unreachable’.
* src/compare.c (dumpdir_cmp): Tell GCC that the default case
is unreachable.  Make just one pass through the string,
instead of two passes (one via strcmp, another via strlen).

12 months agomaint: make a few funcs and vars static
Paul Eggert [Sat, 27 Jul 2024 06:42:59 +0000 (23:42 -0700)] 
maint: make a few funcs and vars static

* src/buffer.c (last_stat_time, write_fatal_details):
* src/tar.c (name_more_files):
* src/xattrs.c (xheader_xattr_add):
Now static.

12 months agomaint: remove GLOBAL as per GCC 14
Paul Eggert [Sat, 27 Jul 2024 06:26:24 +0000 (23:26 -0700)] 
maint: remove GLOBAL as per GCC 14

* src/common.h (GLOBAL): Remove this macro, and all its uses.
It collides with GCC 14 and -Wmissing-variable-declarations.
Change all uses of GLOBAL to use extern instead,
and declare the variables in their respective .c files.
Move .c file’s extern declarations here, so that they
appear only once and are checked against definitions.
* src/names.c (unconsumed_option_tail): Now static.

12 months agoModernize use of Gnulib, paxutils
Paul Eggert [Sat, 27 Jul 2024 04:55:31 +0000 (21:55 -0700)] 
Modernize use of Gnulib, paxutils

* configure.ac: Omit stuff no longer needed now that Gnulib or
paxlib does it, or the code no longer needs the configure-time checks.
Do not use AC_SYS_LARGEFILE (Gnulib largefile does this) or check
for fcntl.h, memory.h, net/errno.h, sgtty.h, string.h,
sys/param.h, sys/device.h, sys/gentape.h, sys/inet.h,
sys/io/trioctl.h, sys/time.h, sys/tprintf.h, sys/tape.h, unistd.h,
locale.h, netdb.h; these are all now standard, or old ways of getting
at magtapes are no longer needed and we now have only sys/mtio.h.
Do not check for lstat, readlink, symlink, and check only for
waitpid’s existence rather than attempting to replace it.
Do not check for decls of getgrgid, getpwuid, or time.
Check just once for iconv.h.
* gnulib.modules: Add largefile.
* lib/.gitignore, lib/Makefile.am (noinst_HEADERS, libtar_a_SOURCES):
Remove system-ioctl.h, which is no longer in paxlib.
All includes now changed to just check HAVE_SYS_MTIO_H directly.
* lib/wordsplit.c (wordsplit_c_escape_tab, wordsplit_errstr)
(wordsplit_nerrs):
Now static or an enum, and without any leading "_" in the name.
* src/buffer.c (record_start, record_end, current_block, records_read):
* src/delete.c (records_skipped): Add extern decl to pacify GCC.
* src/compare.c, src/create.c, src/extract.c: Omit uses of
HAVE_READLINK and HAVE_SYMLINK since we now let Gnulib deal with
platforms lacking readlinkat and symlinkat.
* src/system.c: Use "#if !HAVE_WAITPID" instead of "#if MSDOS".

12 months agobuild: update gnulib and paxutils submodules to latest
Paul Eggert [Fri, 26 Jul 2024 20:27:46 +0000 (13:27 -0700)] 
build: update gnulib and paxutils submodules to latest

12 months agomaint: higher-precision checkpoint timestamps
Paul Eggert [Wed, 24 Jul 2024 16:45:46 +0000 (09:45 -0700)] 
maint: higher-precision checkpoint timestamps

* src/checkpoint.c (format_checkpoint_string):
Use current_timespec to get nanosecond resolution.
This also frees us from the necessity of including <sys/time.h>
to use gettimeofday, which is removed in POSIX.1-2024.

12 months agobuild: update gnulib and paxutils submodules to latest
Paul Eggert [Wed, 24 Jul 2024 02:54:08 +0000 (19:54 -0700)] 
build: update gnulib and paxutils submodules to latest

12 months agoSync bootstrap from Gnulib
Paul Eggert [Wed, 24 Jul 2024 02:52:33 +0000 (19:52 -0700)] 
Sync bootstrap from Gnulib

12 months agoSync bootstrap from Gnulib
Paul Eggert [Mon, 15 Jul 2024 21:53:10 +0000 (14:53 -0700)] 
Sync bootstrap from Gnulib

12 months agomaint: adjust to Gnulib -Wsystem-headers change
Paul Eggert [Mon, 15 Jul 2024 21:51:53 +0000 (14:51 -0700)] 
maint: adjust to Gnulib -Wsystem-headers change

* configure.ac: Do not suppress -Wsystem-headers, as
Gnulib no longer enables it.

12 months agobuild: update gnulib submodule to latest
Paul Eggert [Mon, 15 Jul 2024 21:50:55 +0000 (14:50 -0700)] 
build: update gnulib submodule to latest

14 months agoVarious formatting fixes
Sergey Poznyakoff [Thu, 6 Jun 2024 21:05:00 +0000 (00:05 +0300)] 
Various formatting fixes

14 months agoFix spurious diagnostic during extraction of . with --keep-newer-files
Sergey Poznyakoff [Wed, 5 Jun 2024 15:19:10 +0000 (18:19 +0300)] 
Fix spurious diagnostic during extraction of . with --keep-newer-files

Bug reported in https://savannah.gnu.org/bugs/?65838.

Bug introduced by 79d1ac38c1.

* src/extract.c (make_directories): Restore second argument.  This
reverts the change made in 79d1ac38c1.
(maybe_recoverable, rename_directory): Update calls to make_directories.
* tests/extrac27.at: New file.
* tests/Makefile.am: Add new test.
* tests/testsuite.at: Likewise.

17 months agotar: fix current_block confusion
Paul Eggert [Sun, 3 Mar 2024 21:27:32 +0000 (13:27 -0800)] 
tar: fix current_block confusion

Problem reported by Robert Morris in:
https://lists.gnu.org/r/bug-tar/2024-03/msg00001.html
* src/delete.c (flush_file): Simply return at EOF,
so that current_block continues to point to end of input.

17 months agotar: fix unlikely overflow
Paul Eggert [Sun, 3 Mar 2024 21:20:23 +0000 (13:20 -0800)] 
tar: fix unlikely overflow

* src/delete.c (flush_file): Fix arithmetic overflow if
TYPE_MAXIMUM (off_t) - BLOCKSIZE < current_stat_info.stat.st_size.

17 months agotar: improve diagnostic for truncated archive
Paul Eggert [Sun, 3 Mar 2024 21:17:32 +0000 (13:17 -0800)] 
tar: improve diagnostic for truncated archive

* src/buffer.c (seek_archive): If EOF has been read, don’t attempt
to seek past it.  This replaces a bogus "rmtlseek not stopped at a
record boundary" message with a better "Unexpected EOF in archive"
when I run ‘tar tvf gtar13c.tar’ using the gtar13.tar file here:
https://lists.gnu.org/r/bug-tar/2024-03/msg00001.html

18 months agoAvoid gcc 13 "unused parameter" warnings
Sergey Poznyakoff [Tue, 16 Jan 2024 12:28:19 +0000 (14:28 +0200)] 
Avoid gcc 13 "unused parameter" warnings

18 months agoRecognize suffixes .z (gzip) and .tzo (lzop)
Sergey Poznyakoff [Mon, 15 Jan 2024 20:52:27 +0000 (22:52 +0200)] 
Recognize suffixes .z (gzip) and .tzo (lzop)

18 months agoFix description of the CACHEDIR.TAG file.
Sergey Poznyakoff [Mon, 15 Jan 2024 20:26:06 +0000 (22:26 +0200)] 
Fix description of the CACHEDIR.TAG file.

18 months agoFix --exclude-ignore option.
Sergey Poznyakoff [Mon, 15 Jan 2024 19:24:34 +0000 (21:24 +0200)] 
Fix --exclude-ignore option.

This fixes https://savannah.gnu.org/bugs/?64387.

* src/exclist.c (info_attach_exclist): Always use file->flags.
(exclude_vcs_ignores): Pass flags from struct vcs_ignore_file
to excfile_add.

* tests/exclude19.at: New test.
* tests/exclude20.at: New test.
* tests/Makefile.am: Add new tests.
* tests/testsuite.at: Add new tests.

18 months agoFix missing space in the manual
Sergey Poznyakoff [Mon, 15 Jan 2024 18:21:26 +0000 (20:21 +0200)] 
Fix missing space in the manual

18 months agoWhen given -c -a, issue a warning if no compressor is associated with the suffix.
Sergey Poznyakoff [Sun, 14 Jan 2024 21:54:33 +0000 (23:54 +0200)] 
When given -c -a, issue a warning if no compressor is associated with the suffix.

* src/suffix.c (find_compression_suffix): Always return stripped
archive name length in the last argument.  Return 0 if there is no
suffix.
(find_compression_program): Remove.
(set_compression_program_by_suffix): Take third argument, controlling
whether to issue a warning if no suitable compression program is found
for the suffix.
* src/common.h (set_compression_program_by_suffix): Change prototype.
* src/buffer.c, src/tar.c: All uses of set_compression_program_by_suffix
changed.

19 months agoPort EOF detection test to macOS
Paul Eggert [Tue, 2 Jan 2024 03:09:59 +0000 (19:09 -0800)] 
Port EOF detection test to macOS

* tests/delete06.at: Don’t assume the diagnostic is
“Value too large for defined data type”, as strerror
uses a different wording on macOS 12.6.

19 months agoSkip test on macOS 12.6
Paul Eggert [Tue, 2 Jan 2024 03:09:59 +0000 (19:09 -0800)] 
Skip test on macOS 12.6

* tests/xform04.at: Skip test on macOS 12.6, which is behind the times
and doesn’t think that ⱥ (U+2C65 LATIN SMALL LETTER A WITH STROKE) is
printable.

19 months agoPort --numeric-owner basic tests to macOS
Paul Eggert [Tue, 2 Jan 2024 03:09:59 +0000 (19:09 -0800)] 
Port --numeric-owner basic tests to macOS

* tests/numeric.at: If chown fails, skip the test.
This is needed on macOS 12.6 if the user has group
ID 4294967295 (nogroup), which chown rejects.

19 months agoUpdate copyright years
Paul Eggert [Tue, 2 Jan 2024 03:01:15 +0000 (19:01 -0800)] 
Update copyright years

UPDATE_COPYRIGHT_USE_INTERVALS=1 \
gnulib/build-aux/update-copyright \
  $(git ls-files | sed -e '/^gnulib$/d
   /^paxutils$/d
   /^COPYING$/d
   /\/fdl.texi$/d')
sed -i '2000,${
    /^Copyright @copyright/d
    s/^[0-9]*--\(2024 Free Software Foundation, Inc.\)/Copyright (C) \1/
  }' doc/tar.texi

19 months agodoc: fix date in example
Paul Eggert [Tue, 2 Jan 2024 02:54:58 +0000 (18:54 -0800)] 
doc: fix date in example

* doc/tar.texi: Fix copyright date in example.

19 months agobuild: update gnulib submodule to latest
Paul Eggert [Tue, 2 Jan 2024 02:35:11 +0000 (18:35 -0800)] 
build: update gnulib submodule to latest

22 months agoSupport multi-byte --transform='...\L...' etc
Paul Eggert [Wed, 13 Sep 2023 04:21:18 +0000 (23:21 -0500)] 
Support multi-byte --transform='...\L...' etc

Support upcasing and downcasing in multi-byte locales.
* gnulib.modules: Add c32rtomb, c32tolower, c32toupper,
mbrtoc32-regular.
* src/transform.c: Do not include ctype.h.  Include mcel.h.
(stk, stk_init): Move up.
(run_case_conv): Return void, not char *.  Append result to
stk directly; this avoids the need for a separate allocation.
All callers changed.  Do not assume a single-byte locale.
* tests/xform04.at: New test.
* tests/Makefile.am (TESTSUITE_AT):
* tests/testsuite.at: Add it.

22 months agoSimplify wordsplit_string_unquote_copy
Paul Eggert [Tue, 12 Sep 2023 05:33:55 +0000 (00:33 -0500)] 
Simplify wordsplit_string_unquote_copy

* lib/wordsplit.c (wordsplit_string_unquote_copy): Simplify.

22 months agoParse in a more locale-independent way
Paul Eggert [Tue, 12 Sep 2023 05:15:52 +0000 (00:15 -0500)] 
Parse in a more locale-independent way

update submodules to latest
* gnulib.modules: Add c-ctype.
* lib/wordsplit.c, src/buffer.c, src/exclist.c, src/incremen.c:
* src/list.c, src/misc.c, src/names.c, src/sparse.c, src/tar.c:
* src/xheader.c:
Include c-ctype.h, and use its API rather than ctype.h’s.
This is more likely to work when oddball locales are used.
* src/transform.c: Include ctype.h, since this module still uses
tolower and toupper (this is probably wrong - should be multi-byte).

22 months agoUse single is_octal_digit function
Paul Eggert [Tue, 12 Sep 2023 05:33:15 +0000 (00:33 -0500)] 
Use single is_octal_digit function

* src/list.c (ISOCTAL): Remove.
(is_octal_digit): New static function.
All uses of ISOCTAL and ISODIGIT replaced with is_octal_digit.

23 months agomaint: fix THANKS misspellings
Paul Eggert [Mon, 11 Sep 2023 14:32:18 +0000 (09:32 -0500)] 
maint: fix THANKS misspellings

* THANKS: Fix recently-introduced misspellings.

23 months agoFix pointer bug in drop_volume_label_suffix
Paul Eggert [Mon, 11 Sep 2023 06:17:02 +0000 (01:17 -0500)] 
Fix pointer bug in drop_volume_label_suffix

Problem reported by Marc Espie in:
https://lists.gnu.org/r/bug-tar/2023-09/msg00003.html
* src/buffer.c (drop_volume_label_suffix):
Redo to not compute a pointer before the start of a buffer,
as this is not portable.

23 months agoquote unknown header keywords in diagnostics
Paul Eggert [Mon, 11 Sep 2023 06:17:02 +0000 (01:17 -0500)] 
quote unknown header keywords in diagnostics

* src/xheader.c (decx): Quote unknown header in warning, as it may
contain control characters.  Problem reported by Wicher Minnaard.

23 months agoPrefer mcel to mbuiter
Paul Eggert [Sun, 10 Sep 2023 17:10:52 +0000 (10:10 -0700)] 
Prefer mcel to mbuiter

Prefer the lighter-weight mcel implementation to the heavier-weight
mbuiter that GNU tar does not need.
* bootstrap.conf (avoided_gnulib_modules): Avoid mbuiter, mbuiterf.
* gnulib.modules: Add mcel-prefer.

23 months agobuild: update gnulib submodule to latest
Paul Eggert [Sun, 10 Sep 2023 16:38:29 +0000 (09:38 -0700)] 
build: update gnulib submodule to latest

23 months ago.gitmodules: switch to HTTPS
Markus Mayer [Thu, 7 Sep 2023 20:30:58 +0000 (13:30 -0700)] 
.gitmodules: switch to HTTPS

HTTPS is not only encrypted but also better suited for corporate
firewalls. Let's use it to clone submodules.
Copyright-paperwork-exempt: yes

23 months agodocs: replace references to fileutils with coreutils.
Sergey Poznyakoff [Tue, 22 Aug 2023 20:55:09 +0000 (23:55 +0300)] 
docs: replace references to fileutils with coreutils.

GNU fileutils is decommissioned and superseded by coreutils.
This fixes Savannah bug #64495.

23 months agoFix Savane bug #64581
Sergey Poznyakoff [Tue, 22 Aug 2023 15:18:31 +0000 (18:18 +0300)] 
Fix Savane bug #64581

This reverts commit 4f3824743f50808a0079e6057107de53c4a25f22.

23 months agoBump extrac26 timeout
Paul Eggert [Mon, 21 Aug 2023 20:41:42 +0000 (13:41 -0700)] 
Bump extrac26 timeout

* tests/extrac26.at: Increase timeout from 15 to 60 s.
On my old machine it took 15 s.

23 months agoSimplify recently-added hash code
Paul Eggert [Mon, 21 Aug 2023 20:40:37 +0000 (13:40 -0700)] 
Simplify recently-added hash code

* src/extract.c (delay_set_stat): Simplify hash lookup;
no need to initialize members other than file_name.
Avoid assignment in ‘if’ when it’s easy.
(extract_finish): Do not bother to free when we are about to exit.

23 months agoFix O(n^2) time bug in --delay-directory-restore
Benjamin Woodruff [Mon, 21 Aug 2023 20:06:45 +0000 (13:06 -0700)] 
Fix O(n^2) time bug in --delay-directory-restore

delayed_set_stat avoids inserting duplicate entries into
delayed_set_stat_head. It was doing this by scanning the entire
list.

Normally this list is small, but if --delay-directory-restore is
used (including automatically for incremental archives), this list
grows with the total number of directories in the archive.

The entire scan takes O(n) time. Extracting an archive with n
directories could therefore take O(n^2) time.

The included test uses AT_SKIP_LARGE_FILES, allowing it to optionally be
skipped. It may execute slowly on certain filesystems or disks, as it
creates thousands of directories.

There are still potentially problematic O(n) scans in
find_direct_ancestor and remove_delayed_set_stat, which this patch does
not attempt to fix.

* NEWS: Update.
* src/extract.c (delayed_set_stat_table): Create a table for O(1)
lookups of entries in the delayed_set_stat_head list. The list
remains, as tracking insertion order is important.
(dl_hash, dl_compare): New hash table helper functions.
(delay_set_stat): Create the hash table, replace the O(n) list scan
with a hash_lookup, insert new entries into the hash table.
(remove_delayed_set_stat): Also remove entry from hash table.
(apply_nonancestor_delayed_set_stat): Also remove entry from hash
table.
(extract_finish): Free the (empty) hash table.
* tests/extrac26.at: New file.
* tests/Makefile.am (TESTSUITE_AT): Include extrac26.at.
* tests/testsuite.at: Include extrac26.at.

23 months agoPacify gcc -Wanalyzer-fd-use-without-check
Paul Eggert [Mon, 21 Aug 2023 19:52:14 +0000 (12:52 -0700)] 
Pacify gcc -Wanalyzer-fd-use-without-check

* src/system.c (sys_exec_setmtime_script):
Treat fds with more care.

23 months agobuild: update gnulib submodule to latest
Paul Eggert [Mon, 21 Aug 2023 19:36:34 +0000 (12:36 -0700)] 
build: update gnulib submodule to latest

23 months agoRevert "Fix savannah bug #63567"
Sergey Poznyakoff [Fri, 11 Aug 2023 18:35:30 +0000 (21:35 +0300)] 
Revert "Fix savannah bug #63567"

Commit e89c7a45eb broke deletion from archives. The reported number
of bytes read is rounded to the nearest record anyway, revert the
commit and document the fact.

Reported by Ed Santiago. See
https://bugzilla.redhat.com/show_bug.cgi?id=2230127

* doc/tar.texi: Document the fact that --totals rounds up the
number of bytes reads to the nearest record.
* src/buffer.c: Revert changes.
* tests/delete06.at: Fix expected status code and stderr.

2 years agoStop using alloca
Paul Eggert [Wed, 2 Aug 2023 15:41:12 +0000 (08:41 -0700)] 
Stop using alloca

* gnulib.modules: Remove alloca.
* src/create.c (dump_file0): Return address of any allocated
storage.  Caller changed to free it.  Use xmalloc instead
of alloca, to obtain this storage.
* src/list.c (from_header): Use quote_mem instead of quote,
removing the need to use alloca.

2 years agoNew option: --set-mtime-command
Sergey Poznyakoff [Tue, 1 Aug 2023 12:39:15 +0000 (15:39 +0300)] 
New option: --set-mtime-command

* NEWS: Document new option.
* src/common.h (COMMAND_MTIME): New constant.
* src/create.c (set_mtime_command)
(set_mtime_format): New globals.
(sys_exec_setmtime_script): New prototype.
* src/system.c (start_header): Handle COMMAND_MTIME.
* src/tar.c (sys_exec_setmtime_script): New function.

2 years ago* doc/tar.texi: Fix minor reproducibility typos.
Paul Eggert [Tue, 25 Jul 2023 16:45:46 +0000 (09:45 -0700)] 
* doc/tar.texi: Fix minor reproducibility typos.

2 years agoImprove reproducibility recipe
Paul Eggert [Tue, 25 Jul 2023 16:43:16 +0000 (09:43 -0700)] 
Improve reproducibility recipe

* doc/tar.texi (Reproducibility): Improve index.
Improve and add comments to recipe.  In the recipe,
don’t worry about file names beginning with ‘-’ for simplicity;
don’t use touch -c as it exits with status 0 even when it
does not work; and set directory timestamps too.

2 years ago* doc/tar.texi: Define reproducibility.
Sergey Poznyakoff [Tue, 25 Jul 2023 12:30:51 +0000 (14:30 +0200)] 
* doc/tar.texi: Define reproducibility.

2 years agoNew doc about reproducible archives
Paul Eggert [Mon, 24 Jul 2023 21:43:30 +0000 (14:43 -0700)] 
New doc about reproducible archives

* doc/tar.texi (Reproducibility): New section.
Spruce some other sections related to timestamps etc.

2 years agotests: fix LDADD
Paul Eggert [Wed, 19 Jul 2023 22:48:25 +0000 (15:48 -0700)] 
tests: fix LDADD

Problem reported by Christian Weisgerber <naddy@mips.inka.de> in:
https://lists.gnu.org/r/bug-tar/2023-07/msg00015.html
* tests/Makefile.am (LDADD): Add $(LIBINTL), $(LIBICONV).

2 years agotests: Fix xz tests by unsetting XZ_OPT, XZ_DEFAULTS
Sam James [Tue, 18 Jul 2023 15:51:52 +0000 (16:51 +0100)] 
tests: Fix xz tests by unsetting XZ_OPT, XZ_DEFAULTS

Copyright-paperwork-exempt: true

2 years agotests: Fix bashism in testsuite.at
Sam James [Tue, 18 Jul 2023 15:45:32 +0000 (16:45 +0100)] 
tests: Fix bashism in testsuite.at

&> is a bashism and causes various tests to fail with /bin/sh as non-bash
(e.g. dash). Use the same pattern the rest of the file uses instead of &>.

Copyright-paperwork-exempt: true

2 years agotests: fix TESTSUITE_AT
Paul Eggert [Tue, 18 Jul 2023 16:15:03 +0000 (09:15 -0700)] 
tests: fix TESTSUITE_AT

Problem reported by Lukas Javorsky <ljavorsk@redhat.com> in:
https://lists.gnu.org/r/bug-tar/2023-07/msg00002.html
* tests/Makefile.am (TESTSUITE_AT): Add exclude17.at, exclude18.at.
Remove compress.m4; all uses changed.  Add a comment saying how
to rederive this.  Sort.

2 years agoFix savannah bug #64441
Sergey Poznyakoff [Tue, 18 Jul 2023 14:02:23 +0000 (17:02 +0300)] 
Fix savannah bug #64441

* src/Makefile.am (tar_LDADD): Add libiconv libraries.

2 years agoVersion 1.35 v1.35
Sergey Poznyakoff [Tue, 18 Jul 2023 06:38:30 +0000 (09:38 +0300)] 
Version 1.35

2 years agoUse full-read instead of safe-read
Sergey Poznyakoff [Sat, 15 Jul 2023 15:06:27 +0000 (18:06 +0300)] 
Use full-read instead of safe-read

This helps handle archiving on certain filesystems where read()
returns less bytes than requested when reading from a regular
file.

References:

  https://savannah.gnu.org/bugs/index.php?64426
  https://lists.gnu.org/archive/html/bug-tar/2021-07/msg00001.html

* gnulib.modules: Add full-read.
* src/common.h: Include full-read.h
* src/misc.c: Use full_read.
* src/sparse.c: Likewise.
* src/update.c: Likewise.

2 years agoFix typo in comments
Sergey Poznyakoff [Tue, 11 Jul 2023 06:12:47 +0000 (09:12 +0300)] 
Fix typo in comments

This and the bug fixed by the previous commit were reported by
Benno Schulenberg.

2 years agoFix --update --wildcards
Sergey Poznyakoff [Mon, 10 Jul 2023 18:09:57 +0000 (21:09 +0300)] 
Fix --update --wildcards

* src/common.h (name): New field: is_wildcard.
(name_scan): Change protoype.
* src/delete.c: Update calls to name_scan.
* src/names.c (addname, add_starting_file): Initialize is_wildcard.
(namelist_match): Take two arguments.  If second one is true, return
only exact matches.
(name_scan): Likewise.  All callers updated.
(name_from_list): Skip patterns.
* src/update.c (remove_exact_name): New function.
(update_archive): Do not remove matching name, if it is a pattern.
Instead, add a new entry with the matching file name.

* tests/update04.at: New test.
* tests/Makefile.am: Add new test.
* tests/testsuite.at: Include new test.

* NEWS: Update.

2 years agoVarious fixes in the documentation
Benno Schulenberg [Mon, 10 Jul 2023 07:39:48 +0000 (10:39 +0300)] 
Various fixes in the documentation

* doc/tar.1: Add missing dots, use plural when necessary,
tweak a wording.  Remove an incorrect observation, three times.
Add some missing articles, correct some formatting,
and expand the opaque descriptions of two options.
* doc/tar.texi: Drop a stray `cd` command from an example.
Correct two cross references, correct the paragraph
about the manpage, and unbreak a URL.
* src/names.c: Correct and shorten an error message: "non-optional"
means "mandatory", but "non-option" is what was meant.  And the
phrase "in archive create or update mode" was both unneeded and
incomplete.
* tests/positional01.at: Change expected error text.
* tests/positional02.at: Likewise.
* tests/positional03.at: Likewise.

2 years agobuild: update gnulib submodule to latest
Paul Eggert [Wed, 28 Jun 2023 18:31:23 +0000 (11:31 -0700)] 
build: update gnulib submodule to latest

2 years agotar: extract delayed links in order
Paul Eggert [Sun, 25 Jun 2023 19:54:20 +0000 (12:54 -0700)] 
tar: extract delayed links in order

Extract delayed links in tar file order, rather than
in hash table order with modifications.
This is simpler and more likely to use the kernel’s
cached filesystem data, assuming related delayed links
are nearby in the tar file.
* src/extract.c (struct delayed_link.has_predecessor):
Remove.  All uses removed.
(delayed_link_head, delayed_link_tail): New static vars.
This resurrects delayed_link_head’s old function
except that the linked list is now in forward order, not reverse.
(find_delayed_link_source): Now simply returns bool,
since the callers no longer need the pointer.
(create_placeholder_file):
Put the delayed link at the end of the linked list.
Omit no-longer-needed last arg.  All callers changed.
(apply_delayed_links): Simplify now that we can just iterate
through the delayed_link_head list.

2 years agotar: make safe for -Wunused-parameter
Paul Eggert [Sun, 25 Jun 2023 20:54:14 +0000 (13:54 -0700)] 
tar: make safe for -Wunused-parameter

This also ports to C23 [[maybe_unused]].
* configure.ac (WARN_CFLAGS): Do not add -Wno-unused-parameter.
Add MAYBE_UNUSED where needed in source code.
Also, put it at the front where C23 requires it.

2 years ago* po/.gitignore: Omit redundant *~ entries.
Paul Eggert [Sun, 25 Jun 2023 18:35:49 +0000 (11:35 -0700)] 
* po/.gitignore: Omit redundant *~ entries.

2 years agotar: omit unnecessary freeing
Paul Eggert [Sun, 25 Jun 2023 18:33:01 +0000 (11:33 -0700)] 
tar: omit unnecessary freeing

* src/tar.c (main): Omit unnecessary freeing.

2 years agoMake sure each delayed link entry is visited once
Sergey Poznyakoff [Sat, 17 Jun 2023 08:16:12 +0000 (11:16 +0300)] 
Make sure each delayed link entry is visited once

* src/extract.c (create_placeholder_file): Use FLEXNSIZEOF (overlooked
by c542d3d0c8)
(apply_delayed_links): Don't follow the "next" chain after its entries
have been applied.