3353 Commits

Author SHA1 Message Date
Paul Eggert
c5b86d7672 build: document WERROR_CFLAGS
* README-hacking: Mention 'make WERROR_CFLAGS='.
2021-09-18 08:16:04 -07:00
Paul Eggert
c0bf6a723b build: update paxutils submodule to latest 2021-09-17 12:57:14 -07:00
Paul Eggert
b44c612f5d 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.
2021-09-17 12:57:14 -07:00
Paul Eggert
066f7729e0 Pacify gcc -Warray-parameter
* src/common.h (code_timespec): Declare sbuf arg to be an array,
to be consistent with definition.
2021-09-17 12:57:14 -07:00
Paul Eggert
7958eb97e6 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.
2021-09-17 12:57:14 -07:00
Sergey Poznyakoff
66262c10d1 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.
2021-09-02 21:01:58 +03:00
Sergey Poznyakoff
a339f05cd2 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
2021-08-28 17:40:57 +03:00
Sergey Poznyakoff
cc8f5f78b2 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.
2021-08-28 14:15:25 +03:00
Sergey Poznyakoff
193eb8f81d 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.
2021-08-28 09:57:26 +03:00
Samanta Navarro
93082d6eb8 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=\"
2021-07-01 09:52:42 +03:00
Sergey Poznyakoff
e5bc23efcc 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.
2021-07-01 09:38:35 +03:00
Sergey Poznyakoff
12d67f44de Minor fix
* scripts/backup-specs: Set standard paths for rsh (patch#9275).
2021-06-01 19:02:42 +03:00
Samanta Navarro
3730dddb3f Fix typos
Typos found with codespell
2021-06-01 18:54:07 +03:00
Samanta Navarro
8e82f367d4 Minor changes.
* src/xheader.c (decode_record): Fix format specification.
(xattr_encode_keyword): Allocate space for terminating \0.
2021-06-01 18:49:28 +03:00
Sergey Poznyakoff
66b59fccb1 Fix gendocs_template 2021-03-24 20:56:54 +02:00
Paul Eggert
91c031678d 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.
2021-03-07 18:30:08 -08:00
Paul Eggert
5227d66b3c 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.
2021-03-07 18:30:08 -08:00
Paul Eggert
f51461d8be Port xattr-at.h to AIX 7.1
* lib/xattr-at.h: Include <errno.h> before testing whether
ENOATTR is defined.
2021-03-07 18:30:08 -08:00
Paul Eggert
6efa8de409 build: update gnulib submodule to latest 2021-03-07 18:30:08 -08:00
Sergey Poznyakoff
c67d223854 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.
2021-03-01 20:44:31 +02:00
Paul Eggert
55f2a0772e 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'.
2021-03-01 00:18:44 -08:00
Paul Eggert
daf634c44e 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.
2021-03-01 00:18:44 -08:00
Paul Eggert
5f8f129415 Pacify clang for unreachable ‘return’
* src/sparse.c (sparse_scan_file_seek): Omit unreachable statement.
2021-03-01 00:18:44 -08:00
Paul Eggert
dc101747e8 Pacify clang char conversion
* src/create.c (to_chars): Pacify ‘clang’ about assigning
128 to ‘char’.
2021-03-01 00:18:44 -08:00
Paul Eggert
7fb1b6877f 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.
2021-03-01 00:18:44 -08:00
Paul Eggert
f4e2411bf5 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__.
2021-03-01 00:18:44 -08:00
Paul Eggert
ace146f6a4 Update paxutils from upstream 2021-03-01 00:18:43 -08:00
Paul Eggert
df6de51574 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.
2021-02-27 18:40:49 -08:00
Paul Eggert
8378991cba 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.
2021-02-27 16:42:49 -08:00
Paul Eggert
fa6d317bc7 Update gnulib and paxutils from upstream 2021-02-27 16:42:49 -08:00
Pavel Raiskup
beeb19f927 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.
2021-02-08 17:50:31 +02:00
Sergey Poznyakoff
553210d5ad 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.
2021-02-08 16:15:22 +02:00
Sergey Poznyakoff
ee2ec5ff19 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.
2021-02-04 16:51:38 +02:00
Sergey Poznyakoff
d9d4435692 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.
2021-01-17 20:41:11 +02:00
Sergey Poznyakoff
2251317e3f Fix improper argument reference.
(bug introduced by 1ff0b63f)

* src/tar.c (parse_default_options): Pass args as is to the argp_parse.
2021-01-17 19:02:47 +02:00
Sergey Poznyakoff
972bebf07e Fix regression itroduced by 66162927.
* src/misc.c (chdir_arg): Initialize the abspath field to NULL.
(tar_getcdpath): Actually initialize the abspath field here.
2021-01-16 14:38:28 +02:00
Sergey Poznyakoff
8e2898ab11 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.
2021-01-14 09:00:12 +02:00
Sergey Poznyakoff
0b43ea2906 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.
2021-01-08 18:50:57 +02:00
Sergey Poznyakoff
e4d1edadef 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.
2021-01-08 17:46:32 +02:00
Sergey Poznyakoff
0836a51147 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.
release_1_33
2021-01-07 16:33:49 +02:00
Sergey Poznyakoff
afa743ac23 Update copyright years 2021-01-06 17:55:16 +02:00
Sergey Poznyakoff
01dd89c121 Fix typo in the manpage
* doc/tar.1: Fix description of the --newer option
2020-07-13 09:01:29 +03:00
Pavel Raiskup
1263f9bc1d 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.
2020-07-10 09:06:42 +03:00
Sergey Poznyakoff
1ff0b63f48 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.
2020-06-24 16:43:26 +03:00
Sergey Poznyakoff
34d15af170 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.
2020-06-22 22:17:46 +03:00
Sergey Poznyakoff
63712973c7 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.
2020-06-15 21:10:46 +03:00
Alfred M. Szmidt
d9ec6f04e2 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.
2020-06-10 21:56:54 +03:00
Sergey Poznyakoff
b5418cd393 Fix typo in docs 2020-06-03 10:55:51 +03:00
Sergey Poznyakoff
615732a804 Bugfix
* src/sparse.c (sparse_diff_file): Fix return value.
2020-06-03 09:31:41 +03:00
Paul Eggert
dd1a6bd37a 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'.
2020-05-19 11:52:26 -07:00