]> git.ipfire.org Git - thirdparty/tar.git/log
thirdparty/tar.git
2 years agoFix --delete bug with short reads
Paul Eggert [Fri, 2 Sep 2022 21:32:27 +0000 (16:32 -0500)] 
Fix --delete bug with short reads

* gnulib.modules: Add idx.
* src/common.h: Include idx.h.
* src/delete.c (move_archive): Don’t botch short reads.

2 years agoDo not diagnose same xattr file twice
Paul Eggert [Fri, 26 Aug 2022 21:38:29 +0000 (16:38 -0500)] 
Do not diagnose same xattr file twice

* src/extract.c (set_xattr): Simplify, by having it do only
the mknodat and xattrs_xattrs_set, rather than also
trying to recover from failure.  Caller simplified too.
* tests/xattr07.at (xattrs: xattrs and --skip-old-files):
Adjust test to match fixed behavior.

2 years agoFix bug with -x --xattr read-only files
Paul Eggert [Fri, 26 Aug 2022 20:23:23 +0000 (15:23 -0500)] 
Fix bug with -x --xattr read-only files

Problem reported by Kevin Raymond in:
https://bugzilla.redhat.com/show_bug.cgi?id=1886540
* src/extract.c (open_output_file): If we already created the
empty file, do not open with O_EXCL, or with O_CREAT or O_TRUNC
for that matter.  Instead, use only O_NOFOLLOW to avoid some
races.  When estimating current mode, use openflag & O_EXCL rather
than overwriting_old_files.
(extract_file): Also invert S_IWUSR if it’s not set.
* tests/xattr08.at: New test.
* tests/Makefile.am, tests/testsuite.at: Add it.

2 years agoAvoid quadratic behavior with delayed links
Paul Eggert [Mon, 15 Aug 2022 07:05:53 +0000 (00:05 -0700)] 
Avoid quadratic behavior with delayed links

Do this by searching a hash table instead of a linked list.
Problem reported by Martin Dørum in https://mort.coffee/home/tar/
via Gavin Smith in:
https://lists.gnu.org/r/bug-tar/2022-07/msg00003.html
* src/extract.c: Include hash.h.
Improve performance a bit on non-birthtime hosts
(struct delayed_link.has_predecessor): New member.
(delayed_link_head): Remove, replacing with ...
(delayed_link_table): ... this new variable.  All uses
of linked list replaced with hash table.
(dl_hash, dl_compare): New functions for hash table.
(create_placeholder_file): Initialize has_predecessor.
(apply_delayed_link): New function, with body taken from
most of the old apply_delayed_link.
(apply_delayed_links): Use it.  Respect has_predecessor.
Don’t bother freeing as we are about to exit.

2 years agoImprove performance a bit on non-birthtime hosts
Paul Eggert [Mon, 15 Aug 2022 06:16:42 +0000 (23:16 -0700)] 
Improve performance a bit on non-birthtime hosts

* src/extract.c (HAVE_BIRTHTIME, BIRTHTIME_EQ): New macros.
(struct delayed_link, create_placeholder_file, extract_link)
(apply_delayed_links): Avoid unnecessary work on platforms
like GNU/Linux that lack birthtime.

2 years agoAvoid excess lseek etc.
Paul Eggert [Sun, 14 Aug 2022 23:32:26 +0000 (16:32 -0700)] 
Avoid excess lseek etc.

* src/buffer.c, src/delete.c: Do not include system-ioctl.h.
* src/buffer.c (guess_seekable_archive): Remove.  This is now done
by get_archive_status, in a different way.
(get_archive_status): New function that gets archive_stat
unless remote, and sets seekable_archive etc.
(_open_archive): Prefer bool for boolean.
(_open_archive, new_volume): Get archive status consistently
by calling get_archive_status in both places.
* src/buffer.c (backspace_output):
* src/compare.c (verify_volume):
* src/delete.c (move_archive):
Let mtioseek worry about mtio.
* src/common.h (archive_stat): New global, replacing ar_dev and
ar_ino.  All uses changed.
* src/delete.c (move_archive): Check for integer overflow.
Also report overflow if the archive position would go negative.
* src/system.c: Include system-ioctl.h, for MTIOCTOP etc.
(mtioseek): New function, which also checks for integer overflow.
(sys_save_archive_dev_ino): Remove.
(archive_stat): Now
(sys_get_archive_stat): Also initialize mtioseekable_archive.
(sys_file_is_archive): Don’t return true if the archive is /dev/null
since it’s not a problem in that case.
(sys_detect_dev_null_output): Cache dev_null_stat.

doc: omit MS-DOS mentions in doc
It’s really FAT32 we’re worried about now, not MS-DOS.
And doschk is no longer a GNU program.

2 years agoOmit MS-DOS mentions in doc
Paul Eggert [Mon, 25 Jul 2022 23:15:20 +0000 (16:15 -0700)] 
Omit MS-DOS mentions in doc

It’s really FAT32 we’re worried about now, not MS-DOS.
And doschk is no longer a GNU program.

3 years agoWork around GCC bug 106436
Paul Eggert [Mon, 25 Jul 2022 16:41:49 +0000 (09:41 -0700)] 
Work around GCC bug 106436

* src/tar.c (optloc_eq): Use ‘assume’ to pacify GCC bug.

3 years agoAvoid unlikely crash when xasprintf returns 0
Paul Eggert [Sun, 24 Jul 2022 23:18:03 +0000 (16:18 -0700)] 
Avoid unlikely crash when xasprintf returns 0

Problem caught by GCC 12.
* src/tar.c (easprintf): New static function, which never returns
a null pointer.  All uses of xasprintf replaced by uses of this
function.

3 years agoUpdate .gitignore
Paul Eggert [Sun, 24 Jul 2022 22:50:36 +0000 (15:50 -0700)] 
Update .gitignore

* .gitignore: Redo for current sources.

3 years agoFix minor type confusion
Paul Eggert [Sun, 24 Jul 2022 21:51:12 +0000 (14:51 -0700)] 
Fix minor type confusion

* src/tar.c (decode_options): Don’t assign ‘false’ to a pointer.

3 years agoWork around GCC bug 106428
Paul Eggert [Sun, 24 Jul 2022 21:39:11 +0000 (14:39 -0700)] 
Work around GCC bug 106428

* src/names.c (read_next_name): Reword and clarify
to avoid GCC bug 106428.

3 years agoWork around GCC bug 106427
Paul Eggert [Sun, 24 Jul 2022 21:38:34 +0000 (14:38 -0700)] 
Work around GCC bug 106427

* lib/wordsplit.c (coalesce_segment): Reword to avoid
GCC bug 106427.

3 years agoAdjust to Gnulib bootstrap revamp
Paul Eggert [Sun, 24 Jul 2022 18:44:12 +0000 (11:44 -0700)] 
Adjust to Gnulib bootstrap revamp

* autogen.sh, autopull.sh, bootstrap-funclib.sh:
New files, copied from gnulib/top.
* bootstrap: Copy from gnulib/top/bootstrap (as opposed
to copying from gnulib/build-aux/bootstrap, as we used to).
* bootstrap.conf (bootstrap_post_pull_hook)
(bootstrap_post_import_hook): New functions.
Move commands into these functions as needed.

3 years ago* doc/tar.1: Fix --xattrs-exclude typo.
Paul Eggert [Mon, 11 Jul 2022 15:34:25 +0000 (10:34 -0500)] 
* doc/tar.1: Fix --xattrs-exclude typo.

3 years agoAvoid EOVERFLOW problems in some symlink tests
Paul Eggert [Tue, 14 Jun 2022 00:02:54 +0000 (17:02 -0700)] 
Avoid EOVERFLOW problems in some symlink tests

* src/extract.c (is_directory_link): New arg ST.  Caller changed.
(is_directory_link, open_output_file):
Use readlinkat, not fstatat, to determine whether a string
names a symlink.  This avoids EOVERFLOW issues.
(extract_dir): Avoid duplicate calls to fstatat when
keep_directory_symlink_option && fstatat_flags == 0
and the file is a symlink to an existing file.

3 years agoFix ‘make dist-xz’ bug
Paul Eggert [Mon, 13 Jun 2022 23:49:55 +0000 (16:49 -0700)] 
Fix ‘make dist-xz’ bug

Problem reported by Pavel Raiskup in:
https://lists.gnu.org/r/bug-tar/2022-06/msg00014.html
* bootstrap.conf (copy_files): Also copy DISTFILES.

3 years agoFix commentary in new test case
Paul Eggert [Mon, 13 Jun 2022 21:56:45 +0000 (14:56 -0700)] 
Fix commentary in new test case

3 years agoFix doc -c typo
Paul Eggert [Mon, 13 Jun 2022 03:33:09 +0000 (20:33 -0700)] 
Fix doc -c typo

https://lists.gnu.org/r/bug-tar/2022-06/msg00006.html
* doc/tar.texi (Extended File Attributes): Fix typo.

3 years agoUpdate to current Autoconf & Gettext
Paul Eggert [Mon, 13 Jun 2022 00:51:35 +0000 (17:51 -0700)] 
Update to current Autoconf & Gettext

* acinclude.m4, configure.ac:
Use AS_HELP_STRING, not AC_HELP_STRING.
* bootstrap: Sync from Gnulib.
* configure.ac: Require Autoconf 2.71 and Gettext 0.21.
Use AC_PROG_CC, not AC_PROG_CC_STDC.
Prefer AC_COMPILE_IFELSE to AC_TRY_COMPILE.
Use AC_CONFIG_FILES.
* gnulib.modules: Use gettext-h, not gettext.

3 years agobuild: update gnulib and paxutils submodules to latest
Paul Eggert [Sun, 12 Jun 2022 21:14:13 +0000 (14:14 -0700)] 
build: update gnulib and paxutils submodules to latest

3 years agotar: fix race condition
James Abbatiello [Sat, 11 Jun 2022 01:25:13 +0000 (18:25 -0700)] 
tar: fix race condition

Problem reported in:
https://lists.gnu.org/r/bug-tar/2022-03/msg00000.html
* src/extract.c (make_directories): Retry the file creation as
long as the directory exists, regardless of whether tar itself
created the directory.
Copyright-paperwork-exempt: Yes

3 years agotar: fix race condition
Paul Eggert [Fri, 10 Jun 2022 05:09:34 +0000 (22:09 -0700)] 
tar: fix race condition

Problem reported by James Abbatiello in:
https://lists.gnu.org/r/bug-tar/2022-03/msg00000.html
* src/extract.c (make_directories): Do not assume that when
mkdirat fails with errno == EEXIST that there is an existing file
that can be statted.  It could be a dangling symlink.  Instead,
wait until the end and stat it.

3 years agotest: new test extrac25.at
Paul Eggert [Fri, 10 Jun 2022 22:12:17 +0000 (15:12 -0700)] 
test: new test extrac25.at

* tests/Makefile.am (TESTSUITE_AT): Add extrac25.at.
* tests/extrac25.at: New file.
* tests/testsuite.at: Include it.

3 years agoWarn “file changed as we read it” less often
Paul Eggert [Thu, 9 Jun 2022 22:50:06 +0000 (15:50 -0700)] 
Warn “file changed as we read it” less often

* src/create.c (dump_file0): Remove an fstatat call that is
unnecessary because the file wasn’t read so we can treat the first
fstatat as atomic.  Warn “file changed” when the file’s size,
mtime, user ID, group ID, or mode changes, instead of when the
file’s size or ctime changes.  Also, when such a change happens,
do not change exit status if --ignore-failed-read.  Finally, don’t
attempt to change atime back if it didn’t change.

3 years agoModernize NEWS hook to current Emacs
Paul Eggert [Thu, 9 Jun 2022 21:42:14 +0000 (14:42 -0700)] 
Modernize NEWS hook to current Emacs

3 years agodoc: fix abrupt sentence in HTML
Paul Eggert [Tue, 3 May 2022 22:25:03 +0000 (15:25 -0700)] 
doc: fix abrupt sentence in HTML

Typo reported by Jackson Dougherty in:
https://lists.gnu.org/r/bug-tar/2022-05/msg00000.html
* doc/tar.texi: Don’t assume that tex and info are the only two
formats.

3 years agotar: revamp "file is the archive" diagnostic
Paul Eggert [Wed, 16 Feb 2022 01:40:34 +0000 (17:40 -0800)] 
tar: revamp "file is the archive" diagnostic

* src/create.c (dump_file0): For clarity, change diagnostic
wording from "file is the archive; not dumped" to "archive cannot
contain itself; not dumped".  All test cases and documentation changed.

3 years agoUpdate copyright years
Sergey Poznyakoff [Sun, 2 Jan 2022 08:25:29 +0000 (10:25 +0200)] 
Update copyright years

3 years agoCopy COPYING and fdl.texi from upstream
Paul Eggert [Mon, 13 Dec 2021 23:45:52 +0000 (15:45 -0800)] 
Copy COPYING and fdl.texi from upstream

3 years agoFormat ` and ' more nicely in doc
Paul Eggert [Mon, 13 Dec 2021 23:44:26 +0000 (15:44 -0800)] 
Format ` and ' more nicely in doc

Use @documentencoding and set txicodequoteundirected and
txicodequotebacktick to get nicer-looking quoting in the manual.

3 years agoDon’t recommend delete=mtime
Paul Eggert [Mon, 13 Dec 2021 23:27:52 +0000 (15:27 -0800)] 
Don’t recommend delete=mtime

That stops working after the year 2242.

3 years agoMore reproducible tarball doc
Paul Eggert [Mon, 13 Dec 2021 20:42:11 +0000 (12:42 -0800)] 
More reproducible tarball doc

* doc/tar.texi (PAX keywords): Improve discussion of how
to generate reproducible tarballs.

3 years agoRaise version number
Sergey Poznyakoff [Mon, 13 Dec 2021 14:14:26 +0000 (16:14 +0200)] 
Raise version number

3 years ago.gitignore maintenance (some automated)
Paul Eggert [Mon, 13 Dec 2021 08:44:01 +0000 (00:44 -0800)] 
.gitignore maintenance (some automated)

3 years agobootstrap: copy from Gnulib
Paul Eggert [Mon, 13 Dec 2021 07:34:06 +0000 (23:34 -0800)] 
bootstrap: copy from Gnulib

3 years agobuild: update gnulib and paxutils submodules to latest
Paul Eggert [Mon, 13 Dec 2021 00:04:39 +0000 (16:04 -0800)] 
build: update gnulib and paxutils submodules to latest

3 years agoAdd NEWS items for changes since 1.34
Paul Eggert [Sun, 12 Dec 2021 21:03:36 +0000 (13:03 -0800)] 
Add NEWS items for changes since 1.34

3 years agoOmit unnecessary devmajor and devminor setting
Paul Eggert [Sun, 12 Dec 2021 23:30:49 +0000 (15:30 -0800)] 
Omit unnecessary devmajor and devminor setting

* src/create.c (dump_file0): Omit redundant setting of devmajor
and devminor; start_header already does this.

3 years agoOmit devmajor and devminor for non-special files
Paul Eggert [Sun, 12 Dec 2021 20:40:03 +0000 (12:40 -0800)] 
Omit devmajor and devminor for non-special files

* src/create.c (start_header): Leave the devmajor and devminor
fields empty for files that are not character and block special
devices, even when the archive format is pax, ustar or v7.
This avoids generating irrelevant differences which helps with
reproducible builds, and is more compatible with what Solaris 10
tar does.

3 years agoUse ‘bool’ in create.c
Paul Eggert [Sun, 12 Dec 2021 19:50:26 +0000 (11:50 -0800)] 
Use ‘bool’ in create.c

* src/create.c: Prefer ‘bool’, ‘true’, ‘false’ for booleans.

3 years ago* gnulib.modules: Add year2038.
Paul Eggert [Wed, 13 Oct 2021 21:45:55 +0000 (14:45 -0700)] 
* gnulib.modules: Add year2038.

3 years agobuild: improve build-from-git for older GCCs
Paul Eggert [Mon, 20 Sep 2021 20:11:36 +0000 (13:11 -0700)] 
build: improve build-from-git for older GCCs

configure.ac: Bump GCC version from 4.6 to 11.2 when deciding whether
to default to enabling GCC warnings when --enable-gcc-warnings is not
specified, as older GCCs can generate too many false alarms.  From
a suggestion by Christian Schoenebeck.

3 years agoSimplify wordsplit code a bit
Paul Eggert [Sun, 19 Sep 2021 14:34:53 +0000 (07:34 -0700)] 
Simplify wordsplit code a bit

These changes pacify gcc -Wanalyzer-null-dereference on x86-64 gcc
11.2.1 20210728 (Red Hat 11.2.1-1).
* lib/wordsplit.c (wsnode_tail): Remove unnecessary test.
(coalesce_segment): Coalesce calls to wsnode_len.

3 years agobuild: document WERROR_CFLAGS
Paul Eggert [Sat, 18 Sep 2021 15:16:04 +0000 (08:16 -0700)] 
build: document WERROR_CFLAGS

* README-hacking: Mention 'make WERROR_CFLAGS='.

3 years agobuild: update paxutils submodule to latest
Paul Eggert [Fri, 17 Sep 2021 19:27:29 +0000 (12:27 -0700)] 
build: update paxutils submodule to latest

3 years agobuild: update gnulib submodule to latest
Paul Eggert [Fri, 17 Sep 2021 18:41:55 +0000 (11:41 -0700)] 
build: update gnulib submodule to latest

* src/common.h (get_directory_entries):
Add _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE.
Problem found by gcc -Wsuggest-attribute=malloc and
current Gnulib.

3 years agoPacify gcc -Warray-parameter
Paul Eggert [Fri, 17 Sep 2021 19:48:30 +0000 (12:48 -0700)] 
Pacify gcc -Warray-parameter

* src/common.h (code_timespec): Declare sbuf arg to be an array,
to be consistent with definition.

3 years agoFix null rereference if low-memory
Paul Eggert [Fri, 17 Sep 2021 19:36:13 +0000 (12:36 -0700)] 
Fix null rereference if low-memory

* src/incremen.c (read_incr_db_01): Use xstrdup not strdup.
Problem found by gcc -Wanalyzer-possible-null-argument.

3 years agoProvide functions for manipulating arrays of extended attributes
Sergey Poznyakoff [Thu, 2 Sep 2021 17:41:28 +0000 (20:41 +0300)] 
Provide functions for manipulating arrays of extended attributes

* src/common.h (xheader_xattr_free,xheader_xattr_copy): Remove protos.
(xattr_map_init,xattr_map_copy)
(xattr_map_add,xattr_map_free): New protos.
* src/tar.h (xattr_map): New struct.
(tar_stat_info): Replace xattr_map_size and xattr_map with one
field: xattr_map.
* src/xattrs.c (XATTRS_PREFIX,XATTRS_PREFIX_LEN): New defines.
(xheader_xattr_init,xattr_map_init)
(xattr_map_free,xattr_map_add)
(xheader_xattr_add,xattr_map_copy): New functions.
All uses changed.
* src/create.c (start_header): Update to use struct xattr_map.
* src/extract.c: Update to use struct xattr_map.
* src/tar.c: Likewise.
* src/xheader.c (xheader_xattr_init,xheader_xattr_free)
(xheader_xattr_add,xheader_xattr_copy): Remove.
(xattr_coder,xattr_decoder): Use xattr_map_ functions.

3 years agoFix handling of extended header prefixes
Sergey Poznyakoff [Sat, 28 Aug 2021 13:02:12 +0000 (16:02 +0300)] 
Fix handling of extended header prefixes

* src/xheader.c (locate_handler): Recognize prefix keywords only
when followed by a dot.
(xattr_decoder): Use xmalloc/xstrdup instead of alloc

3 years agoHandle invalid sparse entries in pax header
Sergey Poznyakoff [Sat, 28 Aug 2021 11:15:25 +0000 (14:15 +0300)] 
Handle invalid sparse entries in pax header

* src/sparse.c (pax_decode_header): Check if sp.offset+sp.numbytes
falls within the reported file size.  Check for possible integer
overflow.

3 years agotransform: fix replacement of particular pattern instance
Sergey Poznyakoff [Sat, 28 Aug 2021 06:13:05 +0000 (09:13 +0300)] 
transform: fix replacement of particular pattern instance

This fixes handling of expressions like 's/s/@/2'

Fix suggested by Anthony Heading.

* src/transform.c (_single_transform_name_to_obstack): Avoid duplicating
initial prefix if replace is not needed.

4 years agoFix crash on invalid command line argument
Samanta Navarro [Fri, 11 Jun 2021 11:52:31 +0000 (11:52 +0000)] 
Fix crash on invalid command line argument

The copy_string_unquote function does not handle arguments which only
consist of a single quote. A string is only quoted if two quoting
characters exist.

How to reproduce:

tar --checkpoint-action exec=\"

4 years agoFix the use of options with trailing slash in files-from list
Sergey Poznyakoff [Thu, 1 Jul 2021 06:38:35 +0000 (09:38 +0300)] 
Fix the use of options with trailing slash in files-from list

* src/names.c (read_name_from_file): Do not remove trailing slash
here, since name_buffer might contain an option (e.g. -C /).
(read_next_name): Remove trailing slash when we're sure we're dealing
with a file name.
See 163e96a0.

4 years agoMinor fix
Sergey Poznyakoff [Tue, 1 Jun 2021 16:01:31 +0000 (19:01 +0300)] 
Minor fix

* scripts/backup-specs: Set standard paths for rsh (patch#9275).

4 years agoFix typos
Samanta Navarro [Tue, 1 Jun 2021 11:32:02 +0000 (11:32 +0000)] 
Fix typos

Typos found with codespell

4 years agoMinor changes.
Samanta Navarro [Tue, 1 Jun 2021 15:38:21 +0000 (18:38 +0300)] 
Minor changes.

* src/xheader.c (decode_record): Fix format specification.
(xattr_encode_keyword): Allocate space for terminating \0.

4 years agoFix gendocs_template
Sergey Poznyakoff [Wed, 24 Mar 2021 18:56:54 +0000 (20:56 +0200)] 
Fix gendocs_template

4 years agoTune for single-threaded tar
Paul Eggert [Mon, 8 Mar 2021 02:29:00 +0000 (18:29 -0800)] 
Tune for single-threaded tar

This takes advantage of recent optimizations in Gnulib
for single-threaded programs.
* configure.ac (GNULIB_EXCLUDE_SINGLE_THREAD)
(GNULIB_MBRTOWC_SINGLE_THREAD, GNULIB_REGEX_SINGLE_THREAD)
(GNULIB_WCHAR_SINGLE_LOCALE): Define.

4 years agoPort linking to AIX 7.1
Paul Eggert [Mon, 8 Mar 2021 01:58:58 +0000 (17:58 -0800)] 
Port linking to AIX 7.1

* src/Makefile.am (LDADD): Remove, folding into tar_LDADD.
* src/Makefile.am (tar_LDADD), tests/Makefile.am (LDADD):
Add the libraries gnulib-tool currently recommends: LIB_ACL,
LIB_CLOCK_GETTIME, LIB_GETRANDOM, LIB_HARD_LOCALE, LIB_HAS_ACL,
LIB_MBRTOWC, LIB_SETLOCALE_NULL.  Otherwise, tar won’t link on AIX
7.1 with xlc because the -lpthread option is missing.

4 years agoPort xattr-at.h to AIX 7.1
Paul Eggert [Mon, 8 Mar 2021 01:55:45 +0000 (17:55 -0800)] 
Port xattr-at.h to AIX 7.1

* lib/xattr-at.h: Include <errno.h> before testing whether
ENOATTR is defined.

4 years agobuild: update gnulib submodule to latest
Paul Eggert [Sun, 7 Mar 2021 23:12:51 +0000 (15:12 -0800)] 
build: update gnulib submodule to latest

4 years agoFix building the online version of the manual.
Sergey Poznyakoff [Mon, 1 Mar 2021 18:30:56 +0000 (20:30 +0200)] 
Fix building the online version of the manual.

* doc/Makefile.am (GENDOCS): Use the version from the tar repository.
(manual): Set the DISTRIN rendition.
(manual-rebuild): New goal.
* doc/README.manual: New file. Instructions for maintainers on how to
update web documentation.
* doc/gendocs.sh: A version from gnulib fixed as per
https://lists.gnu.org/archive/html/bug-gnulib/2021-03/msg00002.html.
* doc/gendocs_template: Updated version from gnulib.
* doc/intern.texi: Fix the use of UNREVISED.
* doc/tar.texi: Fix the use of GNUTAR.

4 years agoFix unlikely uninitalized var bug with sparse file
Paul Eggert [Mon, 1 Mar 2021 07:23:16 +0000 (23:23 -0800)] 
Fix unlikely uninitalized var bug with sparse file

* src/sparse.c (sparse_extract_file): Set *SIZE to
stat.st_size so that the caller does not use *SIZE
when uninitalized.  Problem found with GCC 10 and
--enable-gcc-warnings CFLAGS='-O2 -flto -fanalyzer'.

4 years agoPacify --enable-gcc-warnings -flto -fanalyzer
Paul Eggert [Mon, 1 Mar 2021 07:21:27 +0000 (23:21 -0800)] 
Pacify --enable-gcc-warnings -flto -fanalyzer

With GCC 10.2.1, ‘./configure --enable-gcc-warnings CFLAGS='-O2
-flto -fanalyzer' issued a false alarm about uninitialized
variable use.  Pacify GCC by using a variant of the code.
* src/buffer.c (zip_program): Omit last placeholder entry.
(n_zip_programs): New constant.
(find_zip_program): Use it instead of placeholder.
(first_decompress_program): Set *PSTATE to maximum value
if skipping the table.  This avoids confusing gcc -flto
into thinking *PSTATE is used uninitialized.
(next_decompress_program): Simplify now that *PSTATE is maximal
when skipping.

4 years agoPacify clang for unreachable ‘return’
Paul Eggert [Sun, 28 Feb 2021 21:43:58 +0000 (13:43 -0800)] 
Pacify clang for unreachable ‘return’

* src/sparse.c (sparse_scan_file_seek): Omit unreachable statement.

4 years agoPacify clang char conversion
Paul Eggert [Sun, 28 Feb 2021 21:42:49 +0000 (13:42 -0800)] 
Pacify clang char conversion

* src/create.c (to_chars): Pacify ‘clang’ about assigning
128 to ‘char’.

4 years agoOmit most uses of ‘inline’
Paul Eggert [Sun, 28 Feb 2021 21:34:55 +0000 (13:34 -0800)] 
Omit most uses of ‘inline’

With today’s compilers ‘inline’ is typically not needed for
performance (at least the way GNU Tar uses it) and it gets in the
way of portability.
* configure.ac: Omit AC_C_INLINE; no longer needed here.
* lib/attr-xattr.in.h (setxattr, lsetxattr, fsetxattr, getxattr)
(lgetxattr, fgetxattr, listxattr, llistxattr, flistxattr):
* lib/wordsplit.c (skip_delim_internal, skip_delim)
(skip_delim_real, exptab_matches):
* src/delete.c (flush_file):
* src/extract.c (safe_dir_mode):
* src/misc.c (ptr_align):
Now just static, not static inline.
* lib/wordsplit.h (wordsplit_getwords): Remove; no longer used.
* src/common.h (name_more_files): Now COMMON_INLINE, not
extern inline - which is not portable according to C99,
the way we were using it.

4 years agomaint: port better to non-GCC compilers
Paul Eggert [Sun, 28 Feb 2021 02:42:58 +0000 (18:42 -0800)] 
maint: port better to non-GCC compilers

This can be helpful in porting to compilers like Oracle Developer
Studio that support some but not all GCC attributes.
* lib/wordsplit.c (FALLTHROUGH): Remove; now done by attribute.h.
* lib/wordsplit.h (__WORDSPLIT_ATTRIBUTE_FORMAT): Remove;
all uses replaced by ATTRIBUTE_FORMAT.
* lib/wordsplit.h, src/buffer.c, src/common.h, src/compare.c:
* src/sparse.c, src/system.c, src/xheader.c:
Prefer ATTRIBUTE_FORMAT, MAYBE_UNUSED, _Noreturn, etc. to
__attribute__.

4 years agoUpdate paxutils from upstream
Paul Eggert [Sun, 28 Feb 2021 02:42:58 +0000 (18:42 -0800)] 
Update paxutils from upstream

4 years agomaint: 1.34 announcement update
Paul Eggert [Sun, 28 Feb 2021 02:40:49 +0000 (18:40 -0800)] 
maint: 1.34 announcement update

Hand-install 1.34 changes into master.
Evidently these changes were not pushed to savannah,
before I installed further changes today.

4 years agomaint: port to Fedora 33
Paul Eggert [Sun, 28 Feb 2021 00:41:12 +0000 (16:41 -0800)] 
maint: port to Fedora 33

Fedora 33 uses GCC 10.2.1, which is a bit pickier.
* configure.ac: Do not use -Wsystem-headers, as this
runs afoul of netdb.h on Fedora 33.
* gnulib.modules: Add ‘attribute’.
* lib/wordsplit.c (wsnode_new): Return the newly allocated
pointer instead of a boolean, to pacify GCC 10.2.1 which otherwise
complains about use of possibly-null pointers.  All uses changed.
* src/buffer.c (try_new_volume): Don’t assume find_next_block succeeds.
(_write_volume_label): Pacify GCC 10.2.1 with an ‘assume’, since
LABEL must be nonnull here.
* src/common.h (FALLTHROUGH): Remove; now in attribute.h.
Include attribute.h, for ATTRIBUTE_NONNULL.
* src/misc.c (assign_string_or_null): New function,
taking over the old role of assign_string.
(assign_string): Assume VALUE is non-null.
(assign_null): New function, taking over the old
role of assign_string when its VALUE was nonnull.
All callers of assign_string changed to use these functions.
(assign_string_n): Clear *STRING if VALUE is null,
to fix a potential double-free.

4 years agoUpdate gnulib and paxutils from upstream
Paul Eggert [Sat, 27 Feb 2021 23:37:40 +0000 (15:37 -0800)] 
Update gnulib and paxutils from upstream

4 years agoxattrs: fix capabilities root test
Pavel Raiskup [Mon, 8 Feb 2021 15:50:31 +0000 (17:50 +0200)] 
xattrs: fix capabilities root test

Related discussion in the Fedora pull-request:
https://src.fedoraproject.org/rpms/tar/pull-request/8

* tests/capabs_raw01.at: Newer systems (currently e.g. Fedora 34)
print getcap output in format CAP=VAL, not CAP+VAL.

4 years agoGracefully handle duplicate symlinks when extracting
Sergey Poznyakoff [Mon, 8 Feb 2021 14:11:41 +0000 (16:11 +0200)] 
Gracefully handle duplicate symlinks when extracting

If the archive being extracted contains multiple copies
of the same symlink, extract only the first of them and
skip the rest.  The use case is described in

https://lists.gnu.org/archive/html/bug-tar/2021-01/msg00026.html

The bug was introduced by 2d3396c3ea.

* src/extract.c (create_placeholder_file): If placeholder already
exists and is registered in the delayed_link list, return immediately.

4 years agoFix savannah bug #60002
Sergey Poznyakoff [Thu, 4 Feb 2021 14:51:38 +0000 (16:51 +0200)] 
Fix savannah bug #60002

Bug was introduced by commit 34d15af1.

* src/extract.c (prepare_to_extract): When extracting over pipe,
process only regular files.
* tests/extrac24.at: New test case.
* tests/Makefile.am: Add new test case.
* tests/testsuite.at: Likewise.

4 years agoFix memory leak in read_header
Sergey Poznyakoff [Sun, 17 Jan 2021 18:41:11 +0000 (20:41 +0200)] 
Fix memory leak in read_header

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

* src/list.c (read_header): Don't return directly from the loop.
Instead set the status and break.  Return the status.  Free
next_long_name and next_long_link before returning.

4 years agoFix improper argument reference.
Sergey Poznyakoff [Sun, 17 Jan 2021 17:02:47 +0000 (19:02 +0200)] 
Fix improper argument reference.

(bug introduced by 1ff0b63f)

* src/tar.c (parse_default_options): Pass args as is to the argp_parse.

4 years agoFix regression itroduced by 66162927.
Sergey Poznyakoff [Sat, 16 Jan 2021 12:36:40 +0000 (14:36 +0200)] 
Fix regression itroduced by 66162927.

* src/misc.c (chdir_arg): Initialize the abspath field to NULL.
(tar_getcdpath): Actually initialize the abspath field here.

4 years agoFixes in the delete_archive_members function
Sergey Poznyakoff [Thu, 14 Jan 2021 07:00:12 +0000 (09:00 +0200)] 
Fixes in the delete_archive_members function

* src/delete.c (delete_archive_members): Clean-up the code. Avoid
entering the loop from the middle.  Free the memory allocated for
current_stat_info.

4 years agoUse stdopen from gnulib
Sergey Poznyakoff [Fri, 8 Jan 2021 16:48:17 +0000 (18:48 +0200)] 
Use stdopen from gnulib

* gnulib.modules: Request stdopen
* lib/Makefile.am: Remove stdopen.c and stdopen.h
* lib/stdopen.c: Remove.
* lib/stdopen.h: Remove.
* src/tar.c: stdopen returns 0 on success.

4 years agoActually prefer /dev/full over /dev/null as a replacement for stdin
Sergey Poznyakoff [Fri, 8 Jan 2021 15:34:19 +0000 (17:34 +0200)] 
Actually prefer /dev/full over /dev/null as a replacement for stdin

* lib/stdopen.c (stdopen): Fix improper condition.
Avoid leaking extra file descriptor.
* src/tar.c (main): Set name of the stdout for diagnostics.
Bail out if stdopen fails.

4 years agoVersion 1.33 release_1_33
Sergey Poznyakoff [Thu, 7 Jan 2021 14:23:16 +0000 (16:23 +0200)] 
Version 1.33

* NEWS: Update.
* configure.ac: Raise version number. Require automake 1.15 and
autoconf 2.64.
* gnulib: pull v0.1-4333-g30820c2
* src/names.c: Use hash_remove instead of the deprecated hash_delete.

4 years agoUpdate copyright years
Sergey Poznyakoff [Wed, 6 Jan 2021 15:55:16 +0000 (17:55 +0200)] 
Update copyright years

5 years agoFix typo in the manpage
Sergey Poznyakoff [Mon, 13 Jul 2020 06:01:29 +0000 (09:01 +0300)] 
Fix typo in the manpage

* doc/tar.1: Fix description of the --newer option

5 years agoBugfix --sparse --diff mode
Pavel Raiskup [Thu, 9 Jul 2020 19:22:10 +0000 (21:22 +0200)] 
Bugfix --sparse --diff mode

Originally reported in:
https://bugzilla.redhat.com/show_bug.cgi?id=1853469

* src/sparse.c (check_data_region): Only compare the part of buffer
really fed by safe_read(), not whole rdsize.

5 years agoAccept only position-sensitive (file-selection) options in file list files.
Sergey Poznyakoff [Wed, 24 Jun 2020 13:43:26 +0000 (16:43 +0300)] 
Accept only position-sensitive (file-selection) options in file list files.

Using such options as -f, -z, etc. is senseless in the file list file
and bypasses the option consistency checks in decode_options.  Therefore,
only options related to file selection (a.k.a position-sensitive options)
are allowed in files.

* doc/tar.texi: Document changes.
* src/common.h (tar_args): Move from tar.c
(TAR_ARGS_INITIALIZER): New macro.
* src/names.c: Declare option group identifiers as an enum.
(names_parse_opt): Special handling for ARGP_KEY_ERROR.
(names_argp): Remove static qualifier.
(names_argp_children): Remove.
* src/tar.c: Declare option group identifiers as an enum.
(parse_opt): Special handling for ARGP_KEY_INIT.
(argp_children): New static variable.
(args): Remove static variable.
(more_options): Allow only options from names_argp.
(parse_default_options): Take a pointer to struct tar_args as argument.
Replace the loc member during the call to argp_parse and restore it
afterwards.
(decode_options): Use automatic variable for args.

5 years agoFix the logic of prepare_to_extract.
Sergey Poznyakoff [Mon, 22 Jun 2020 19:17:46 +0000 (22:17 +0300)] 
Fix the logic of prepare_to_extract.

* src/extract.c (prepare_to_extract): Return true to proceed with
the extraction, and false to skip the current member.  If extracting
over a pipe, skip unlinking logic.
(extract_archive): Update accordingly.

5 years agoMake sure link counting works for file names supplied with -T
Sergey Poznyakoff [Mon, 15 Jun 2020 18:10:46 +0000 (21:10 +0300)] 
Make sure link counting works for file names supplied with -T

* src/common.h (name_count): Remove extern.
(files_count): New enum.
(filename_args): New extern.
* src/names.c (name_count): Remove.
(files_count): New variable.
(name_add_name,name_add_file): Update filename_args.
* src/create.c (create_archive): Set trivial_link_count depending on
the filename_args.

5 years agoRemove freemanuals.texi
Alfred M. Szmidt [Wed, 10 Jun 2020 12:26:45 +0000 (08:26 -0400)] 
Remove freemanuals.texi

* doc/Makefile.am (tar_TEXINFOS): Remove freemanuals.texi.
* doc/freemanuals.texi: Delete file.
* doc/tar.texi (Free Software Needs Free Documentation): Remove
appendix.

5 years agoFix typo in docs
Sergey Poznyakoff [Wed, 3 Jun 2020 07:55:51 +0000 (10:55 +0300)] 
Fix typo in docs

5 years agoBugfix
Sergey Poznyakoff [Wed, 3 Jun 2020 06:31:41 +0000 (09:31 +0300)] 
Bugfix

* src/sparse.c (sparse_diff_file): Fix return value.

5 years agotar: avoid read overrun
Paul Eggert [Tue, 19 May 2020 18:52:01 +0000 (11:52 -0700)] 
tar: avoid read overrun

Problem reported by Timotej Kapus in:
https://lists.gnu.org/r/bug-tar/2020-05/msg00001.html
* src/transform.c (parse_transform_expr):
Diagnose ‘--transform='s'’ instead of continuing past '\0'.

5 years agoFix handling of linked rename chains in incremental backups
Sergey Poznyakoff [Sat, 15 Feb 2020 08:57:35 +0000 (10:57 +0200)] 
Fix handling of linked rename chains in incremental backups

* src/incremen.c: Change the meaning of the DIRF_RENAMED flag.  Now it
marks a directory which is the last one in a chain of renames.
Regular renamed directories are recognized by their orig member being
non-NULL.  Directories marked with DIRF_RENAMED start encoding of renames.
(procdir): Clear DIRF_RENAMED flag on directories which are origins for
renames.
(makedumpdir): Use the orig member to check if the directory is a
result of a rename.
(store_rename): Move the check for DIR_IS_RENAMED to the caller. Don't
clear the DIRF_RENAMED, it is not needed any more.

* tests/rename06.at: New test.
* tests/Makefile.am: Add rename06.at
* tests/testsuite.at: Likewise.

5 years agoUpdate copyright years
Sergey Poznyakoff [Sat, 8 Feb 2020 11:21:13 +0000 (13:21 +0200)] 
Update copyright years

5 years agoFix the --no-overwrite-dir option
Sergey Poznyakoff [Sat, 8 Feb 2020 11:01:47 +0000 (13:01 +0200)] 
Fix the --no-overwrite-dir option

Given this option, tar failed to preserve permissions of empty directories
and to create files under directories owned by the current user that did
not have the S_IWUSR bit set.

* src/extract.c (fd_chmod): Rename to fd_i_chmod.
(fd_chmod): New function.
(safe_dir_mode): New function.
(extract_dir): Special handling for existing directories in
--no-overwrite-dir mode.
* tests/extrac23.at: New file.
* tests/Makefile.am: Add new test case.
* tests/testsuite.at: Likewise.

5 years agoWildcards in exclude-vcs-ignore mode should not match slash
Sergey Poznyakoff [Tue, 3 Dec 2019 07:55:02 +0000 (09:55 +0200)] 
Wildcards in exclude-vcs-ignore mode should not match slash

* src/exclist.c (info_attach_exclist): Use the FNM_FILE_NAME flag.

5 years agoVersion 1.32.90
Sergey Poznyakoff [Wed, 27 Nov 2019 16:51:58 +0000 (18:51 +0200)] 
Version 1.32.90

5 years agoTestsuite fixes
Sergey Poznyakoff [Mon, 25 Nov 2019 06:01:04 +0000 (08:01 +0200)] 
Testsuite fixes

* tests/sparse06.at: Skip the test if genfile is unable to create
sparse files.
* tests/sptrcreat.at: Likewise.
* tests/sptrdiff00.at: Likewise.
* tests/sptrdiff01.at: Likewise.