]> git.ipfire.org Git - thirdparty/coreutils.git/log
thirdparty/coreutils.git
63 min agocksum: allow -a {blake2b,sha2,sha3} --check to work on base64 master
Collin Funk [Sun, 5 Oct 2025 00:18:01 +0000 (17:18 -0700)] 
cksum: allow -a {blake2b,sha2,sha3} --check to work on base64

* NEWS: Mention the bug.
* src/digest.c (split_3): Check that the base64 digest matches the
length supported by the algorithm.
(digest_check): Check that the read digest matches the base64 length of
the algorithm's digest. The previous condition would not work for
'cksum -a blake2b -l 8 ...'.
* tests/cksum/cksum-base64-untagged.sh: New file.
* tests/local.mk (all_tests): Add the new test.

47 hours agomaint: omit trailing white space in config.h
Paul Eggert [Sat, 4 Oct 2025 00:04:01 +0000 (17:04 -0700)] 
maint: omit trailing white space in config.h

* configure.ac (FORTIFY_SOURCE): Don’t indent a line
where the indentation can cause trailing white space in config.h.
Problem reported by Grisha Levit (Bug#79567).

2 days agomaint: remove IRIX support
Collin Funk [Fri, 3 Oct 2025 02:15:34 +0000 (19:15 -0700)] 
maint: remove IRIX support

* src/ptx.c (main) [HAVE_SETCHRCLASS]: Remove call to setchrclass.
* src/stty.c (VREPRINT) [!VREPRINT && VRPRNT]: Remove definition.

3 days agotests: factor: add suggested large prime tests
Pádraig Brady [Thu, 2 Oct 2025 16:20:39 +0000 (17:20 +0100)] 
tests: factor: add suggested large prime tests

* tests/factor/create-test.sh: Add 2 new large primes from:
https://github.com/coreutils/coreutils/issues/65
* tests/local.mk: Reference the 2 new generated tests.

3 days agounexpand: fix heap buffer overflow with --tabs=[+/]NUM
Pádraig Brady [Thu, 2 Oct 2025 11:24:20 +0000 (12:24 +0100)] 
unexpand: fix heap buffer overflow with --tabs=[+/]NUM

This avoids CWE-122: Heap-based Buffer Overflow
where we could write blank characters beyond
the allocated heap buffer.

* src/expand-common.c (set_max_column_width): Refactor function from ...
(add_tab_stop): ... here.
(set_extend_size): Call new function.
(set_increment_size): Likewise.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/79555

3 days agodoc: man: consistently format -X[OPTIONAL] form
Pádraig Brady [Wed, 1 Oct 2025 20:20:20 +0000 (21:20 +0100)] 
doc: man: consistently format -X[OPTIONAL] form

This is significant for the date, od, and pr commands
which have options of the form -X[OPTIONAL], which change like:

  diff -r man.orig/date.1 man/date.1
  < \fB\-I[FMT]\fR, \fB\-\-iso\-8601\fR[=\fI\,FMT\/\fR]
  > \fB\-I\fR[\fI\,FMT\/\fR], \fB\-\-iso\-8601\fR[=\fI\,FMT\/\fR]

  diff -r man.orig/od.1 man/od.1
  < \fB\-w[BYTES]\fR, \fB\-\-width\fR[=\fI\,BYTES\/\fR]
  > \fB\-w\fR[\fI\,BYTES\/\fR], \fB\-\-width\fR[=\fI\,BYTES\/\fR]

* man/help2man (convert_options): Support options of the form
-X[PARAM], so that we now consistently format them (in italics).

3 days agodoc: man: consistently italicize --option parameters
Pádraig Brady [Wed, 1 Oct 2025 17:38:21 +0000 (18:38 +0100)] 
doc: man: consistently italicize --option parameters

This changes a few pages, but the changes in tail.1
concisely illustrate the resulting man page changes:

  $ diff -r man.orig/tail.1 man/tail.1
  < \fB\-c\fR, \fB\-\-bytes\fR=\fI\,[\/\fR+]NUM
  > \fB\-c\fR, \fB\-\-bytes\fR=\fI\,[+]NUM\/\fR

  < \fB\-f\fR, \fB\-\-follow[=\fR{name|descriptor}]
  > \fB\-f\fR, \fB\-\-follow\fR[=\fI\,{name|descriptor}\/\fR]

  < \fB\-n\fR, \fB\-\-lines\fR=\fI\,[\/\fR+]NUM
  > \fB\-n\fR, \fB\-\-lines\fR=\fI\,[+]NUM\/\fR

* man/help2man: Relax the option match so more --option
variations are supported, and passed through to convert_option().
Specifically more variations after '=' are now supported.
Also split and document the regular expression.
Reported at https://github.com/coreutils/coreutils/issues/84

3 days agomaint: prefer unreachable () to NOTREACHED comment
Collin Funk [Thu, 2 Oct 2025 06:44:18 +0000 (23:44 -0700)] 
maint: prefer unreachable () to NOTREACHED comment

* src/tsort.c (search_item): Use unreachable () instead of NOTREACHED.

4 days agofold: move multi-byte character reading to a module
Collin Funk [Mon, 29 Sep 2025 03:16:26 +0000 (20:16 -0700)] 
fold: move multi-byte character reading to a module

* gl/modules/mbbuf: New file.
* gl/lib/mbbuf.c: Likewise.
* gl/lib/mbbuf.h: Likewise.
* gl/local.mk (EXTRA_DIST): Add the new files.
* bootstrap.conf (gnulib_modules): Add mbbuf.
* src/fold.c: Include mbbuf.h.
(fold_file): Use the mbbuf functions instead of calling fread and
handling the input buffer ourselves.
* cfg.mk (exclude_file_name_regexp--sc_preprocessor_indentation)
(exclude_file_name_regexp--sc_GPL_version): Match gl/lib/mbbuf.c and
gl/lib/mbbuf.h.

5 days agowc: add AVX512 function for line counting
Mathieu Bordere [Wed, 24 Sep 2025 10:41:06 +0000 (12:41 +0200)] 
wc: add AVX512 function for line counting

* configure.ac: Add detection of AVX512 intrinsics for wc.
* src/local.mk: Build AVX512 wc libraries.
* src/wc.c: Add runtime detection of AVX512 intrinsics and call
appropriate function when detected.
* src/wc.h (wc_lines_avx512): Declare function.
* tests/wc/wc-cpu.sh: Add a test that disables AVX512 intrinsics.
* src/wc_avx512.c: New file containing the wc -l implementation using
AVX512. The logic and code is reused from the AVX2 implementation with
slight adaptations. Replaced __builtin_popcount by __builtin_popcountll
and the combination of _mm256_cmpeq_epi8 and _mm256_movemask_epi8 by a
single call to _mm512_cmpeq_epi8_mask.
* NEWS: Mention the improvement.

8 days agomaint: update valgrind instructions
Pádraig Brady [Sat, 27 Sep 2025 16:44:48 +0000 (17:44 +0100)] 
maint: update valgrind instructions

* README-valgrind: Adjust to current repo structure,
and give clearer step by step instructions.

8 days agomaint: convert some overflow checks to ckd_add and ckd_mul
Collin Funk [Sat, 27 Sep 2025 21:34:44 +0000 (14:34 -0700)] 
maint: convert some overflow checks to ckd_add and ckd_mul

* src/csplit.c (parse_repeat_count): Prefer ckd_add when checking for
overflows.
* src/install.c (get_ids): Likewise.
* src/shred.c (dopass): Likewise.
* src/tr.c (get_spec_stats): Likewise.
* src/sort.c (specify_sort_size): Prefer ckd_mul when checking for
overflows.

9 days agotests: test: ensure file operations are covered
Pádraig Brady [Fri, 26 Sep 2025 15:16:20 +0000 (16:16 +0100)] 
tests: test: ensure file operations are covered

A coverage report indicated these weren't tested
(as generally the test shell builtin is used).

* tests/test/test-file.sh: Add a new test.
* tests/local.mk: Reference the new test.

9 days agojoin: remove unused #include "argmatch.h"
Bernhard Voelker [Thu, 25 Sep 2025 20:50:01 +0000 (22:50 +0200)] 
join: remove unused #include "argmatch.h"

Prompted by the syntax-check failure:
  maint.mk: the above files include argmatch.h but don't use it
  make: *** [maint.mk:741: sc_prohibit_argmatch_without_use] Error 1

* src/join.c: Remove include, as the previous commit changed from using
ARRAY_CARDINALITY to countof - for which system.h includes the header.

10 days agomaint: prefer countof over ARRAY_CARDINALITY
Collin Funk [Wed, 24 Sep 2025 02:17:14 +0000 (19:17 -0700)] 
maint: prefer countof over ARRAY_CARDINALITY

* bootstrap.conf (gnulib_modules): Add stdcountof-h.
* src/system.h: Include stdcountof.h.
(ARRAY_CARDINALITY): Remove definition.
* .gitignore (/lib/stdcountof.h): Ignore Gnulib generated file.
* src/csplit.c: Use countof instead of ARRAY_CARDINALITY.
* src/df.c: Likewise.
* src/digest.c: Likewise.
* src/dircolors.c: Likewise.
* src/factor.c: Likewise.
* src/join.c: Likewise.
* src/ls.c: Likewise.
* src/od.c: Likewise.
* src/sort.c: Likewise.
* src/stdbuf.c: Likewise.
* src/tr.c: Likewise.

11 days agotail: fix tailing larger number of lines in regular files
Hannes Braun [Wed, 24 Sep 2025 19:20:49 +0000 (21:20 +0200)] 
tail: fix tailing larger number of lines in regular files

* src/tail.c (file_lines): Seek to the previous block instead of the
beginning (or a little before) of the block that was just scanned.
Otherwise, the same block is read and scanned (at least partially)
again. This bug was introduced by commit v9.7-219-g976f8abc1.
* tests/tail/basic-seek.sh: Add a new test.
* tests/local.mk: Reference the new test.
* NEWS: mention the bug fix.

11 days agotests: wc: fix hardware acceleration disabling test
Pádraig Brady [Wed, 24 Sep 2025 14:52:36 +0000 (15:52 +0100)] 
tests: wc: fix hardware acceleration disabling test

* tests/wc/wc-cpu.sh: The message is only printed with wc -l.
Reported by Mathieu Borderé.

11 days agobuild: copy: add dependency on $(LIB_SMACK)
Pádraig Brady [Wed, 24 Sep 2025 10:18:52 +0000 (11:18 +0100)] 
build: copy: add dependency on $(LIB_SMACK)

* src/local.mk: Due to gnulib adjustments, this explicit
dependency is required with the mold linker at least.
Reported at https://github.com/coreutils/coreutils/issues/113

12 days agobasenc: --base58: fix buffer overflow with input > 15MB
Pádraig Brady [Tue, 23 Sep 2025 14:38:51 +0000 (15:38 +0100)] 
basenc: --base58: fix buffer overflow with input > 15MB

base58_length() operated naively on an int
which resulted in an overflow to a negative number
for any input > 2^31-1/138, i.e. 15,561,475 bytes.

* src/basenc.c (base_length): Change input and output
parameter types from int to idx_t since this needs to
cater for the full input size in the base58 case.
(base58_length): Likewise.  Also reorder the calculation
to be less exact, but doing the division first
to minimize the chance of overflow (which now on 64 bit
would only happen for inputs > around 6 Exa bytes).
* tests/basenc/basenc-large.sh: Add a new test,
that triggers with valgrind or ASAN.
* tests/local.mk: Reference the new test.
* NEWS: Mention the bug fix.

12 days agodoc: document gl_cv_crc_pclmul to control hardware acceleration
Pádraig Brady [Mon, 22 Sep 2025 19:51:49 +0000 (20:51 +0100)] 
doc: document gl_cv_crc_pclmul to control hardware acceleration

doc/coreutils.texi (Harware acceleration configuration):
Sort the list and add "gl_cv_crc_pclmul".

12 days agobuild: fix build failure with mismatched pclmul
Pádraig Brady [Mon, 22 Sep 2025 19:46:33 +0000 (20:46 +0100)] 
build: fix build failure with mismatched pclmul

* src/cksum.c (pclmul_supported): In the case where
gnulib has pclmul enabled but coreutils does not,
ensure we don't reference the coreutils pclmul function.
Addresses https://bugs.gnu.org/79491

12 days agobuild: update gnulib submodule to latest
Paul Eggert [Tue, 23 Sep 2025 00:43:14 +0000 (17:43 -0700)] 
build: update gnulib submodule to latest

13 days agomaint: post-release administrivia
Pádraig Brady [Mon, 22 Sep 2025 17:23:31 +0000 (18:23 +0100)] 
maint: post-release administrivia

* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.

13 days agoversion 9.8 v9.8
Pádraig Brady [Mon, 22 Sep 2025 16:50:52 +0000 (17:50 +0100)] 
version 9.8

* NEWS: Record release date.

13 days agobuild: update gnulib to latest
Pádraig Brady [Mon, 22 Sep 2025 13:02:23 +0000 (14:02 +0100)] 
build: update gnulib to latest

* gnulib: Update to latest to pull Android build fixes,
and fchownat fixes.

13 days agotests: ls: avoid alignment check with non printable characters
Pádraig Brady [Sun, 21 Sep 2025 23:18:28 +0000 (00:18 +0100)] 
tests: ls: avoid alignment check with non printable characters

* tests/ls/block-size.sh: Skip the case where there are
non-printable characters in ls' output, which is the case
with NBSP thousands separators on FreeBSD 11 and 12.
We may drop the MBSW_REJECT_UNPRINTABLE in future from
ls and numfmt, but for now avoid these characters in the test.
Reported by Bruno Haible.

2 weeks agotests: du: avoid false failure in racy test
Pádraig Brady [Sun, 21 Sep 2025 19:14:10 +0000 (20:14 +0100)] 
tests: du: avoid false failure in racy test

* tests/du/move-dir-while-traversing.sh: Expand the work to avoid
a false failure where du completes before the directory is moved.
Also expand the timeout to our more standard 10s to avoid the
"directory mover" being killed before du processes the directory.
This doesn't perceptibly impact the run time of the test.
Reported by Bruno Haible on a CentOS 7 system.

2 weeks agobuild: revert gnulib update
Pádraig Brady [Sun, 21 Sep 2025 23:06:03 +0000 (00:06 +0100)] 
build: revert gnulib update

There is a pending issue with fchownat:
https://lists.gnu.org/r/bug-gnulib/2025-09/msg00282.html

2 weeks agobuild: update gnulib submodule to latest
Collin Funk [Sun, 21 Sep 2025 22:14:12 +0000 (15:14 -0700)] 
build: update gnulib submodule to latest

2 weeks agobuild: fix missing declarations on Android
Collin Funk [Sun, 21 Sep 2025 20:40:18 +0000 (13:40 -0700)] 
build: fix missing declarations on Android

* configure.ac: Check for statx using gl_CHECK_FUNCS_ANDROID since it is
hidden for Android API level <= 30.
* m4/jm-macros.m4 (coreutils_MACROS): Check for syncfs using
gl_CHECK_FUNCS_ANDROID since it is hidden for Android API level <= 28.

2 weeks agomaint: comment spelling fixes
Paul Eggert [Sun, 21 Sep 2025 18:30:40 +0000 (11:30 -0700)] 
maint: comment spelling fixes

2 weeks agotests: fix OMP_NUM_THREADS misspelling
Paul Eggert [Sun, 21 Sep 2025 18:30:12 +0000 (11:30 -0700)] 
tests: fix OMP_NUM_THREADS misspelling

* tests/nproc/nproc-quota.sh: Fix misspelling.

2 weeks agomaint: update bootstrap from Gnulib
Paul Eggert [Sun, 21 Sep 2025 16:47:03 +0000 (09:47 -0700)] 
maint: update bootstrap from Gnulib

2 weeks agotests: avoid false failure on older Linux kernels
Pádraig Brady [Sun, 21 Sep 2025 15:37:26 +0000 (16:37 +0100)] 
tests: avoid false failure on older Linux kernels

* tests/fold/fold-zero-width.sh: Check the shell was able to create
the redirection file, as intermittently on CentOS 5,6,7 this wasn't
the case, with the shell giving an xmalloc failure due to the ulimit.
Reported by William Bader and Bruno Haible.

2 weeks agotests: tail: avoid false failure with overlayfs
Pádraig Brady [Sun, 21 Sep 2025 12:45:54 +0000 (13:45 +0100)] 
tests: tail: avoid false failure with overlayfs

* tests/tail/inotify-dir-recreate.sh: Add an extra check
that inotify is in use, as it's required for this test.
Inotify is avoided with overlayfs for which the
df --local check is not sufficient exclusion for.

2 weeks agotests: fold: avoid false failures on Solaris 10
Pádraig Brady [Sat, 20 Sep 2025 16:10:30 +0000 (17:10 +0100)] 
tests: fold: avoid false failures on Solaris 10

* tests/fold/fold-characters.sh: Ensure we have independent verification
of the width of characters before testing based on those widths.
* tests/fold/fold-zero-width.sh: Likewise.
* tests/fold/fold.pl: Only compare the exit status,
as the error message can be translated.

2 weeks agotests: dd: avoid false failure on Solaris 10
Pádraig Brady [Sat, 20 Sep 2025 16:46:11 +0000 (17:46 +0100)] 
tests: dd: avoid false failure on Solaris 10

* tests/dd/no-allocate.sh: Give some extra space to the
determined vm limit.

2 weeks agotests: avoid false failure on CentOS 5,6,7
Pádraig Brady [Sat, 20 Sep 2025 15:10:16 +0000 (16:10 +0100)] 
tests: avoid false failure on CentOS 5,6,7

* tests/fold/fold-zero-width.sh: Increase vm limit to avoid
failures on CentOS 5,6,7.  Match the limit used in write-errors.sh
as per commit v9.5-255-g0bd149403

2 weeks agodoc: don't capitalize the first letter of cgroup
Collin Funk [Fri, 19 Sep 2025 01:43:54 +0000 (18:43 -0700)] 
doc: don't capitalize the first letter of cgroup

This is the correct way to write it as described in the documentation:
<https://docs.kernel.org/admin-guide/cgroup-v2.html#terminology>.

* doc/coreutils.texi (nproc invocation): Use cgroup instead of Cgroup.

2 weeks agotests: env: skip a few tests if LD_LIBRARY_PATH is set
Collin Funk [Fri, 19 Sep 2025 23:32:52 +0000 (16:32 -0700)] 
tests: env: skip a few tests if LD_LIBRARY_PATH is set

* tests/env/env-null.sh: Skip test if LD_LIBRARY_PATH or platform's
equivalent is set, since 'env -i' will unset it which may prevent
programs from running.
* tests/env/env-S.pl: Likewise.
Issue and suggested fix reported by Bruno Haible.

2 weeks agotouch: fix diagnostic on macOS 26
Grisha Levit [Fri, 19 Sep 2025 00:40:59 +0000 (20:40 -0400)] 
touch: fix diagnostic on macOS 26

* src/touch.c (touch): Do not use open_errno == EEXIST for diagnostic
if file was a directory as macOS 26 sets it for open("/", O_CREAT, ...).

2 weeks agocopy: pacify older clang
Paul Eggert [Fri, 19 Sep 2025 15:55:12 +0000 (08:55 -0700)] 
copy: pacify older clang

* src/copy-file-data.c (copy_file_data):
Redo conditionals for clarity.
This pacifies the clang in FreeBSD 11 and OpenBSD 7.6.
Problem reported by Bruno Haible in:
https://lists.gnu.org/r/coreutils/2025-09/msg00104.html

2 weeks agodd: don't mistakenly use O_EXCL on GNU/Hurd
Collin Funk [Fri, 19 Sep 2025 06:29:02 +0000 (23:29 -0700)] 
dd: don't mistakenly use O_EXCL on GNU/Hurd

* src/dd.c (v): Add the O_EXCL flag to the set of bits that we do not
want to use for our definitions.
* cfg.mk (sc_dd_O_FLAGS): Adjust to pass syntax-check.
* NEWS: Mention the fix.
Reported by Bruno Haible.

2 weeks agomaint: we don’t use Gnulib’s fchownat module
Paul Eggert [Fri, 19 Sep 2025 00:07:38 +0000 (17:07 -0700)] 
maint: we don’t use Gnulib’s fchownat module

* bootstrap.conf (gnulib_modules): Remove fchownat.
It is used only indirectly, via the chownat module.

2 weeks agofmt: eliminate a clang -Wformat-extra-args warning
Bruno Haible [Thu, 18 Sep 2025 21:05:06 +0000 (23:05 +0200)] 
fmt: eliminate a clang -Wformat-extra-args warning

* src/fmt.c (fmt): When not reading from stdin, always mention the
file name in the error message.

2 weeks agomaint: we use Gnulib’s stddef-h module directly
Paul Eggert [Thu, 18 Sep 2025 21:22:39 +0000 (14:22 -0700)] 
maint: we use Gnulib’s stddef-h module directly

* bootstrap.conf (gnulib_modules): Add stddef-h, since the code
uses ‘unreachable’ which is supplied by that module.

2 weeks agotests: tail/overlay-headers.sh: protect against hang
Pádraig Brady [Thu, 18 Sep 2025 18:04:57 +0000 (19:04 +0100)] 
tests: tail/overlay-headers.sh: protect against hang

* tests/tail/overlay-headers.sh: Protect tail invocation with timeout,
and extend the possible running period to 60 seconds like other tests.
Reported by Brudno Haible on T2SDE Linux/alpha

2 weeks agobuild: fix compile error on macOS
Pádraig Brady [Thu, 18 Sep 2025 17:04:57 +0000 (18:04 +0100)] 
build: fix compile error on macOS

* gnulib: Update to latest to pull fix
for localcharset compile failure on macOS.

2 weeks agotests: tests/tail/wait.sh: protect against hang
Pádraig Brady [Thu, 18 Sep 2025 16:47:45 +0000 (17:47 +0100)] 
tests: tests/tail/wait.sh: protect against hang

* tests/tail/wait.sh: This test was seen to hang occasionally
on an Alpine Linux 3.20 system, so protect the tail(1) call
with `timeout 60` as done in similar tests.
Reported by Bruno Haible.

2 weeks agobuild: fix link failure on macOS
Pádraig Brady [Thu, 18 Sep 2025 14:34:23 +0000 (15:34 +0100)] 
build: fix link failure on macOS

* src/local.mk: Explicitly depend on @INTL_MACOS_LIBS@
which may be not implicitly referenced (in LIBINTL) without gettext.
This is a new transitive dependency through localename-unsafe.
We add this globally to ease future maintenance as currently
6 commands require the localename-unsafe dependency:
date, du through show-date() (fprintftime), and
ls, pr, stat, uptime through strftime().

2 weeks agobuild: update gnulib for stringeq adjustment
Pádraig Brady [Wed, 17 Sep 2025 20:44:46 +0000 (21:44 +0100)] 
build: update gnulib for stringeq adjustment

* gnulib: Pull in stringeq adjustment.

2 weeks agotests: write-errors.sh: avoid portability issue with dash
Pádraig Brady [Wed, 17 Sep 2025 20:33:47 +0000 (21:33 +0100)] 
tests: write-errors.sh: avoid portability issue with dash

* tests/misc/write-errors.sh: Use printf rather than echo
since the echo builtin in dash will interpret backslashes.
* tests/misc/read-errors.sh: Likewise for consistency.

2 weeks agocksum,wc: inspect GLIBC_TUNABLES on all architectures
Pádraig Brady [Wed, 17 Sep 2025 19:38:53 +0000 (20:38 +0100)] 
cksum,wc: inspect GLIBC_TUNABLES on all architectures

* gnulib: Update gnulib to latest to pull in change
to inspect GLIBC_TUNABLES on non x86_64 or aarch64 platforms.
This was needed on 32 bit x86, which supports calling into
accelerated code, and so requires inspection of GLIBC_TUNABLES
to pass the disablement verification in tests/cksum/cksum.sh

2 weeks agomaint: prefer memeq to memcmp
Paul Eggert [Wed, 17 Sep 2025 19:12:53 +0000 (12:12 -0700)] 
maint: prefer memeq to memcmp

* gl/modules/randread-tests (Depends-on): Add stringeq.
* gl/tests/test-rand-isaac.c (main):
* src/copy.c (source_is_dst_backup):
* src/digest.c (b64_equal):
* src/install.c (have_same_content):
* src/ls.c (main, parse_ls_color):
* src/nl.c (check_section):
* src/od.c (write_block):
* src/seq.c (seq_fast):
* src/stty.c (eq_mode):
* src/system.h (is_nul):
Prefer memeq to memcmp when either will do.

2 weeks agomaint: STREQ → streq
Paul Eggert [Wed, 17 Sep 2025 16:12:23 +0000 (09:12 -0700)] 
maint: STREQ → streq

Use new Gnulib streq function instead of rolling our own macro.
* bootstrap.conf (gnulib_modules): Add stringeq.
* src/rm.c (main): Don’t assume streq is a macro that expands to (...),
as it is now a function.
* src/system.h:
* tests/df/no-mtab-status.sh, tests/df/skip-duplicates.sh:
(STREQ): Remove.  All uses replaced by streq.

2 weeks agobuild: update gnulib submodule to latest
Paul Eggert [Wed, 17 Sep 2025 15:30:21 +0000 (08:30 -0700)] 
build: update gnulib submodule to latest

2 weeks agotests: fix issues with fold-characters.sh test
Pádraig Brady [Wed, 17 Sep 2025 13:17:39 +0000 (14:17 +0100)] 
tests: fix issues with fold-characters.sh test

This was noticed with:

  trap '' PIPE &&  # Ignore SIGPIPE
  make check TESTS=tests/fold/fold-characters.sh SUBDIRS=.

* tests/fold/fold-characters.sh: Move memory limit test to ...
* tests/misc/write-errors.sh: ... which avoids "write error"
messages on stderr due to the ignored SIGPIPE.  It also protects
the fold invocation with a timeout(1) so that fold implementations
that don't exit promptly upon write error don't hang the test suite
(Like we would have done before commit v9.7-311-gc95c7ee76).

2 weeks agodoc: remove older ChangeLog items
Pádraig Brady [Wed, 17 Sep 2025 12:19:32 +0000 (13:19 +0100)] 
doc: remove older ChangeLog items

* Makefile.am: Update the oldest documented version
to 8.32 which is now about 5 years old.

2 weeks agomaint: remove unnecessary uintmaxtostr usage in printf
Collin Funk [Wed, 17 Sep 2025 02:43:46 +0000 (19:43 -0700)] 
maint: remove unnecessary uintmaxtostr usage in printf

* src/comm.c (compare_files): Use the "%ju" printf directive instead of
"%s" and printing the result of umaxtostr.
* src/df.c (get_header): Likewise.
* src/ls.c (print_long_format): Likewise.
* src/sort.c (check): Likewise.

2 weeks agodoc: add hardware acceleration configuration docs
Pádraig Brady [Tue, 16 Sep 2025 21:51:20 +0000 (22:51 +0100)] 
doc: add hardware acceleration configuration docs

* NEWS: Mention the new GLIBC_TUNABLES feature.
* doc/coreutils.texi (Hardware Acceleration): A new node
detailing the build time and run time configuration options.

2 weeks agofold: fix write error checks with invalid multi-byte input
Pádraig Brady [Tue, 16 Sep 2025 15:45:02 +0000 (16:45 +0100)] 
fold: fix write error checks with invalid multi-byte input

* src/fold.c (write_out): A new helper to check all writes.
(fold-file): Use write_out() for all writes.
* tests/fold/fold-zero-width.sh: Adjust to writing more
data in various patterns, rather than two buffers of NULs.
This is a more robust memory bound check, and the '\303' case
tests this particular logic change.
* NEWS: fold now exits immediately, not just promptly.

2 weeks agofold: exit promptly upon write errors
Pádraig Brady [Tue, 16 Sep 2025 12:07:35 +0000 (13:07 +0100)] 
fold: exit promptly upon write errors

* NEWS: Mention the improvement.
* src/fold.c (fold_file): Check for write errors
after each buffer read from stdin.
* tests/misc/write-errors.sh: Add test cases.

2 weeks agomaint: basenc: refactor overloaded use of ctx->i member
Pádraig Brady [Mon, 15 Sep 2025 20:31:00 +0000 (21:31 +0100)] 
maint: basenc: refactor overloaded use of ctx->i member

* src/basenc.c (base_decode_context): Remove the shared "i" member,
instead using per encoding data and access functions
for tracking pending data.

2 weeks agotests: fold/fold-zero-width.sh: avoid false failure with ENOSPC
Pádraig Brady [Tue, 16 Sep 2025 13:00:44 +0000 (14:00 +0100)] 
tests: fold/fold-zero-width.sh: avoid false failure with ENOSPC

* tests/fold/fold-zero-width.sh: Check relatively large test file
is created appropriately.  Also apply more idomatic wc -l usage.

2 weeks agodoc: NEWS: fold: clarify mem exhaustion trigger
Pádraig Brady [Tue, 16 Sep 2025 12:56:35 +0000 (13:56 +0100)] 
doc: NEWS: fold: clarify mem exhaustion trigger

* NEWS: Long lines were not an issue in previously
released coreutils, only the -w limitation was.

2 weeks agomaint: avoid syntax-check failures from recent commits
Pádraig Brady [Tue, 16 Sep 2025 12:42:06 +0000 (13:42 +0100)] 
maint: avoid syntax-check failures from recent commits

* cfg.mk: Avoid spellcheck failures.
* src/copy-file-data.c: Avoid sc_tight_scope and long_lines failure.
* src/copy.h: Avoid indentation issues.

2 weeks agocp: create_hole now returns off_t
Paul Eggert [Fri, 8 Aug 2025 15:45:59 +0000 (08:45 -0700)] 
cp: create_hole now returns off_t

* src/copy-file-data.c (create_hole): Refactor by returning
resulting offset, not bool.  All callers changed.

2 weeks agocp: prefer signed types in copy-file-data.c
Paul Eggert [Wed, 6 Aug 2025 19:11:34 +0000 (12:11 -0700)] 
cp: prefer signed types in copy-file-data.c

* src/copy-file-data.c (sparse_copy, lseek_copy)
(copy_file_data): Prefer idx_t to size_t.
(copy_file_data): Defend against st_size < 0, which can happen on
ancient buggy platforms.  Check for overflow; the old code was
wrong on theoretical-but-valid hosts where SIZE_MAX <= INT_MAX.

2 weeks agocp: don’t allocate a separate zero buffer
Paul Eggert [Wed, 6 Aug 2025 18:48:21 +0000 (11:48 -0700)] 
cp: don’t allocate a separate zero buffer

* src/copy-file-data.c (write_zeros): New args abuf, buf_size.
Use the lazily-allocated buffer, which most likely already exists,
rather than allocating a separate buffer just for zeros.
This makes the code more reentrant as there is no longer
a need for static storage here.  Although there is some CPU
overhead due to the need to zero out the buffer for each file,
the overhead is relatively small as the buffer is smallish
and should be cached.  All callers changed.

2 weeks agocp: refactor copying to return bytes copied
Paul Eggert [Wed, 6 Aug 2025 16:55:41 +0000 (09:55 -0700)] 
cp: refactor copying to return bytes copied

This doesn’t change behavior; it simplifies future changes.
* src/copy-file-data.c (sparse_copy, lseek_copy, copy_file_data):
Return the number of bytes copied, or -1 on failure,
instead of merely returning a success indication.
All callers changed.

2 weeks agocp: copy_file_data now supports ibytes
Paul Eggert [Wed, 6 Aug 2025 14:53:35 +0000 (07:53 -0700)] 
cp: copy_file_data now supports ibytes

This does not affect current coreutils behavior;
it is merely to help make copy_file_data more useful in the future.
* src/copy-file-data.c (lseek_copy): New arg ibytes.
Caller changed.
(copy_file_data): Implement the ibytes arg; formerly
it was always treated as COUNT_MAX, though all callers
currently pass COUNT_MAX so there was no problem in practice.

2 weeks agocp: prefer signed type for file byte count
Paul Eggert [Tue, 5 Aug 2025 22:50:39 +0000 (15:50 -0700)] 
cp: prefer signed type for file byte count

* src/copy-file-data.c (sparse_copy): max_n_read arg is now
of type count_t, not uintmax_t.  This is better for debugging
with -fsanitize=undefined.

2 weeks agocp: port better to old limited hosts
Paul Eggert [Tue, 5 Aug 2025 22:45:35 +0000 (15:45 -0700)] 
cp: port better to old limited hosts

Port better ancient platforms where OFF_T_MAX is only 2**31 - 1,
but some devices have more than that many bytes.
* src/copy-file-data.c (copy_file_data): Byte count is now
count_t, not off_t.  All callers changed.  Since we need to check
for overflow anyway, also check for too-small calls to fadvise.

2 weeks agocp: refactor out data copying
Paul Eggert [Tue, 5 Aug 2025 21:45:18 +0000 (14:45 -0700)] 
cp: refactor out data copying

* po/POTFILES.in, src/local.mk (copy_sources): Add the new file.
* src/copy.c: Move the #includes of alignalloc.h, buffer-lcm.h,
fadvise.h, full-write.h, ioblksize.h to copy-file-data.c.
(enum copy_debug_val, struct copy_debug): Move these decls to copy.h.
(punch_hole, create_hole, is_CLONENOTSUP, sparse_copy)
(write_zeros, lseek_copy, HAVE_STRUCT_STAT_ST_BLOCKS)
(enum scantype, struct scan_inference, infer_scantype):
Move to copy-file-data.c.
(copy_reg): Move the data-copying part of this function
to the new function copy_file_data in copy-file-data.c.
* src/copy-file-data.c: New file, taken from part of copy.c.

2 weeks agocp: refactor src/copy.c
Paul Eggert [Tue, 5 Aug 2025 19:47:16 +0000 (12:47 -0700)] 
cp: refactor src/copy.c

This is in preparation for splitting this large module.
* src/copy.c (sparse_copy, lseek_copy): New arg DEBUG, used to
identify copy debug info instead of using a static var.  All
callers changed.
(lseek_copy, infer_scantype): New args SRC_POS and POS.
Callers changed.
(copy_file_data): New function, with contents taken from copy.
(copy_reg): Call it.

2 weeks agodoc: NEWS: correct the previous commit
Collin Funk [Tue, 16 Sep 2025 04:40:56 +0000 (21:40 -0700)] 
doc: NEWS: correct the previous commit

* NEWS: The memory allocated by 'fold' in the past was also bounded by
--width.

2 weeks agodoc: NEWS: mention fold can operate on very long lines
Collin Funk [Tue, 16 Sep 2025 04:09:42 +0000 (21:09 -0700)] 
doc: NEWS: mention fold can operate on very long lines

* NEWS: Before commit fb9016d50 (fold: use fread instead of getline,
2025-08-24), fold required that the maximum line size in a file fit into
memory. Document that this is no longer the case.

2 weeks agofold: fix out of bounds write with zero width characters
Collin Funk [Tue, 16 Sep 2025 03:53:23 +0000 (20:53 -0700)] 
fold: fix out of bounds write with zero width characters

* src/fold.c (fold_file): Prefer putchar ('\n') to copying characters.
If we do not have room in the output buffer print it since it is not a
full line of text.
* tests/fold/fold-zero-width.sh: New test case.
* tests/local.mk (all_tests): Add it.

2 weeks agocp: improve umask caching
Paul Eggert [Sun, 14 Sep 2025 18:46:28 +0000 (11:46 -0700)] 
cp: improve umask caching

* src/copy.c (cached_umask): Avoid syscalls when cached umask is 0.
This can also help the compiler’s static analysis.

3 weeks agobasenc: fix an uninitialized index when decoding an empty file
Collin Funk [Sun, 14 Sep 2025 05:59:05 +0000 (22:59 -0700)] 
basenc: fix an uninitialized index when decoding an empty file

* src/basenc.c (base64_decode_ctx_init_wrapper)
(base64url_decode_ctx_init_wrapper)
(base32_decode_ctx_init_wrapper)
(base32hex_decode_ctx_init_wrapper): Initialize ctx->i to zero.
Fixes https://bugs.gnu.org/79444

3 weeks agomaint: randperm: remove stale dependency
Pádraig Brady [Fri, 12 Sep 2025 15:23:28 +0000 (16:23 +0100)] 
maint: randperm: remove stale dependency

* gl/modules/randperm: Remove assert-h dependency
not required since commit v9.5-34-g26ba82015

3 weeks agocksum,wc: support disabling hardware acceleration at runtime
Pádraig Brady [Fri, 12 Sep 2025 16:03:11 +0000 (17:03 +0100)] 
cksum,wc: support disabling hardware acceleration at runtime

This is useful to give better test coverage at least,
and may be useful for users to tune their environment.

* bootstrap.conf: Reference the cpu-supports gnulib module.
* src/cksum.c: Use cpu_supports() rather than __builtin_cpu_supports().
* src/wc.c: Likewise.
* tests/cksum/cksum.sh: Adjust to testing all implementations.
* tests/wc/wc-cpu.sh: A new test to do likewise.
* tests/local.mk: Reference the new wc test.

3 weeks agobuild: update gnulib submodule to latest
Pádraig Brady [Sun, 14 Sep 2025 12:31:39 +0000 (13:31 +0100)] 
build: update gnulib submodule to latest

Primarily to get the new cpu-supports module.

3 weeks agofactor: port to strict C
Paul Eggert [Sat, 13 Sep 2025 19:25:36 +0000 (12:25 -0700)] 
factor: port to strict C

Problem found with Oracle Developer Studio 12.6.
* src/factor.c (factor): Don’t return f() when f returns void.

3 weeks agomaint: document some functions used by expand and unexpand
Collin Funk [Fri, 12 Sep 2025 03:31:05 +0000 (20:31 -0700)] 
maint: document some functions used by expand and unexpand

* src/expand-common.h (get_next_tab_column, cleanup_file_list_stdin)
(emit_tab_list_info): Document functions.
* src/expand-common.c (cleanup_file_list_stdin, emit_tab_list_info):
Likewise.

3 weeks agomaint: basenc: refactor all encodings to use finalize
Pádraig Brady [Mon, 8 Sep 2025 16:40:00 +0000 (17:40 +0100)] 
maint: basenc: refactor all encodings to use finalize

Finalize was required for base58, but it's a more general mechanism
which simplifies the logic for all encodings

* src/basenc.c (do_decode): Always call base_decode_ctx_finalize(),
rather than the awkward double loop at end of buffer.
* tests/basenc/basenc.pl: Add basenc finalization tests.

3 weeks agomaint: cleanup libraries unnecessarily added to fold
Collin Funk [Wed, 10 Sep 2025 03:39:37 +0000 (20:39 -0700)] 
maint: cleanup libraries unnecessarily added to fold

* src/local.mk (src_fold_LDADD): Remove $(MBRTOWC_LIB) since it is
already added to LDADD. Remove $(LIBC32CONV) and $(LIBUNISTRING) which
were for an uncommitted patch which used Gnulib's mbfile module.

3 weeks agonohup: avoid FORTIFY runtime failure on Bionic libc
Pádraig Brady [Tue, 9 Sep 2025 11:11:00 +0000 (12:11 +0100)] 
nohup: avoid FORTIFY runtime failure on Bionic libc

The meaning of non-file permission umask bits is implementation defined.
On Bionic libc, attempting to set them triggers a FORTIFY runtime check.

  $ nohup true
  FORTIFY: umask: called with invalid mask -601
  Aborted                    nohup true

* src/nohup.c: (main) Avoid setting non-permission bits in umask.
Just clear the umask to ensure we create nohup.out with u+rw,
as we restore the original umask before the exec().
* tests/misc/nohup.sh: Add a test case.
* NEWS: Mention the bug fix.

3 weeks agobasenc: ensure partial padding with newlines induces an error
Pádraig Brady [Mon, 8 Sep 2025 17:22:20 +0000 (18:22 +0100)] 
basenc: ensure partial padding with newlines induces an error

* src/basenc.c (has_padding): A more robust helper to
identify padding in the presence of trailing newlines.
(do_decode): Use has_padding() rather than just looking
at the last character.
* tests/basenc/base64.pl: Fully test commit v9.4-53-g378dc38f4
by ensuring partially padded data is diagnosed.
baddecode9 is the case fixed in this commit.
* NEWS: Mention the bug fix.

4 weeks agotests: ensure option aliases are supported
Pádraig Brady [Sun, 7 Sep 2025 12:09:06 +0000 (13:09 +0100)] 
tests: ensure option aliases are supported

This implicitly tests the previous commit to
adjust how date(1) handles multiple named format options.
Currrently it tests the following are supported:

  chown  --quiet  --silent
  date  --rfc-email  --rfc-822  --rfc-2822
  date  --uct  --utc  --universal
  dircolors  --bourne-shell  --sh
  dircolors  --csh  --c-shell
  head  --quiet  --silent

* tests/misc/option-aliases.sh: A new test to ensure all
option aliases supported by a command are supported.
* Reference the new test.

4 weeks agodate: support overriding named formats
Pádraig Brady [Sat, 6 Sep 2025 19:41:29 +0000 (20:41 +0100)] 
date: support overriding named formats

* src/date.c (main): Allow specifying different named formats,
with the last specified taking precedence.
* NEWS: Mention the bug fix.

4 weeks agocksum: don't leak memory using -a sha3 with OpenSSL
Collin Funk [Sun, 7 Sep 2025 00:14:47 +0000 (17:14 -0700)] 
cksum: don't leak memory using -a sha3 with OpenSSL

* gnulib: Update to the latest commit for latest changes to the
crypto/sha3-buffer and crypto/sha3 modules.

4 weeks agomaint: prefer c32isspace to iswspace
Collin Funk [Fri, 5 Sep 2025 04:13:43 +0000 (21:13 -0700)] 
maint: prefer c32isspace to iswspace

* src/wc.c (wc): Replace call to iswspace with c32isspace.

4 weeks agotests: fold: check if multi-byte spaces are treated as blank
Collin Funk [Fri, 5 Sep 2025 02:30:00 +0000 (19:30 -0700)] 
tests: fold: check if multi-byte spaces are treated as blank

This avoids a test failure on FreeBSD 14, MacOS 15, and musl.
Fix suggested by Pádraig Brady in:
<https://bugs.gnu.org/79301#32>.
* tests/fold/fold-spaces.sh (isblank): New function. Only run the tests
if the character is treated as blank.
Fixes https://bugs.gnu.org/79301

4 weeks agodoc: update the md5/sha1 "weak hash" advisory
Pádraig Brady [Thu, 4 Sep 2025 17:19:15 +0000 (18:19 +0100)] 
doc: update the md5/sha1 "weak hash" advisory

* doc/coreutils.texi: Adjust advisory for md5sum and sha1sum
to include "sha3", and also the more general `cksum -a` interface.

4 weeks agotests: cksum: check more length variants
Pádraig Brady [Thu, 4 Sep 2025 13:42:03 +0000 (14:42 +0100)] 
tests: cksum: check more length variants

* tests/cksum/cksum-raw.sh: Adjust to non legacy naming,
and also check various length variations.
* tests/misc/read-errors.sh: Likewise.

4 weeks agodoc: NEWS: expand on the fold multi-byte enhancements
Pádraig Brady [Thu, 4 Sep 2025 12:54:01 +0000 (13:54 +0100)] 
doc: NEWS: expand on the fold multi-byte enhancements

* NEWS: Mention all of fold(1) got multi-byte enhancement,
with -c being an ancillary part of that.

4 weeks agocksum: prefer -a sha2 -l ###, to -a sha###
Pádraig Brady [Tue, 2 Sep 2025 14:28:21 +0000 (15:28 +0100)] 
cksum: prefer -a sha2 -l ###, to -a sha###

To make the interface more concise and consistent,
while being backwards compatible.

* src/digest.c (main): Continue to support -a "sha###" but
also support -a "sha2" and treat it like "sha3", except in...
(output_file): ... maintain the legacy tags for better compatability.
* doc/coreutils.texi (cksum invocation): Document the -a sha2 option.
* tests/cksum/cksum-base64.pl: Adjust as per modified --help.
* tests/cksum/cksum-c.sh: Add new supported SHA2-### tagged variant.
* NEWS: Mention the new feature.

4 weeks agocksum: add support for SHA-3
Collin Funk [Sun, 31 Aug 2025 23:56:08 +0000 (16:56 -0700)] 
cksum: add support for SHA-3

* src/digest.c: Include sha3.h.
(BLAKE2B_MAX_LEN): Rename to
DIGEST_MAX_LEN since it is also used for SHA-3.
(sha3_sum_stream): New function.
(enum Algorithm, algorithm_args, algorithm_args, algorithm_types)
algorithm_tags, algorithm_bits, cksumfns, cksum_output_fns): Add entries
for SHA-3.
(usage): Mention that SHA-3 is supported. Mention requirements for
--length with SHA-3.
(split_3): Use DIGEST_MAX_LEN instead of BLAKE2B_MAX_LEN. Determine the
length of the digest for SHA-3. Make sure it is 224, 256, 384, or 512.
(digest_file): Set the digest length in bytes. Use DIGEST_MAX_LEN
instead of BLAKE2B_MAX_LEN. Always append the digest length to SHA3 in
the output.
(main): Allow the use of --length with 'cksum -a sha3'.  Use
DIGEST_MAX_LEN instead of BLAKE2B_MAX_LEN. Make sure it is 224, 256,
384, or 512.
* tests/cksum/cksum-base64.pl (@pairs): Add expected sha3 output.
(fmt): Modify the output to use SHA3-512 since that is the default.
(@Tests): Modify arguments for sha3 to use --length=512.
* tests/cksum/cksum-sha3.sh: New test, based on tests/cksum/b2sum.sh.
* tests/local.mk (all_tests): Add the test.
* bootstrap.conf: Add crypto/sha3.
* gnulib: Update to latest commit.
* NEWS: Mention the change.
* doc/coreutils.texi (cksum general options): Mention sha3 as a
supported argument to the -a option. Mention that 'cksum -a sha3'
supports the --length option. Mention that SHA-3 is considered secure.

4 weeks agomaint: avoid syntax-check failure from previous commit
Collin Funk [Thu, 4 Sep 2025 02:15:49 +0000 (19:15 -0700)] 
maint: avoid syntax-check failure from previous commit

* src/df.c: Don't include uchar.h.
* src/ls.c: Likewise.
* src/wc.c: Likewise.