aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)AuthorFilesLines
2025-09-15cp: refactor copying to return bytes copiedPaul Eggert3-64/+69
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.
2025-09-15cp: copy_file_data now supports ibytesPaul Eggert1-11/+29
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.
2025-09-15cp: prefer signed type for file byte countPaul Eggert1-4/+4
* 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.
2025-09-15cp: port better to old limited hostsPaul Eggert3-5/+14
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.
2025-09-15cp: refactor out data copyingPaul Eggert5-595/+622
* 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.
2025-09-15cp: refactor src/copy.cPaul Eggert1-109/+139
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.
2025-09-15doc: NEWS: correct the previous commitCollin Funk1-1/+2
* NEWS: The memory allocated by 'fold' in the past was also bounded by --width.
2025-09-15doc: NEWS: mention fold can operate on very long linesCollin Funk1-0/+3
* 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.
2025-09-15fold: fix out of bounds write with zero width charactersCollin Funk3-4/+67
* 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.
2025-09-15cp: improve umask cachingPaul Eggert1-2/+4
* src/copy.c (cached_umask): Avoid syscalls when cached umask is 0. This can also help the compiler’s static analysis.
2025-09-14basenc: fix an uninitialized index when decoding an empty fileCollin Funk1-0/+4
* 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
2025-09-14maint: randperm: remove stale dependencyPádraig Brady1-1/+0
* gl/modules/randperm: Remove assert-h dependency not required since commit v9.5-34-g26ba82015
2025-09-14cksum,wc: support disabling hardware acceleration at runtimePádraig Brady6-15/+66
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.
2025-09-14build: update gnulib submodule to latestPádraig Brady1-0/+0
Primarily to get the new cpu-supports module.
2025-09-13factor: port to strict CPaul Eggert1-1/+1
Problem found with Oracle Developer Studio 12.6. * src/factor.c (factor): Don’t return f() when f returns void.
2025-09-11maint: document some functions used by expand and unexpandCollin Funk2-5/+10
* 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.
2025-09-10maint: basenc: refactor all encodings to use finalizePádraig Brady2-60/+107
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.
2025-09-09maint: cleanup libraries unnecessarily added to foldCollin Funk1-3/+0
* 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.
2025-09-09nohup: avoid FORTIFY runtime failure on Bionic libcPádraig Brady3-1/+25
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.
2025-09-08basenc: ensure partial padding with newlines induces an errorPádraig Brady3-3/+29
* 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.
2025-09-07tests: ensure option aliases are supportedPádraig Brady2-0/+62
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.
2025-09-07date: support overriding named formatsPádraig Brady2-12/+7
* src/date.c (main): Allow specifying different named formats, with the last specified taking precedence. * NEWS: Mention the bug fix.
2025-09-06cksum: don't leak memory using -a sha3 with OpenSSLCollin Funk1-0/+0
* gnulib: Update to the latest commit for latest changes to the crypto/sha3-buffer and crypto/sha3 modules.
2025-09-04maint: prefer c32isspace to iswspaceCollin Funk1-1/+1
* src/wc.c (wc): Replace call to iswspace with c32isspace.
2025-09-04tests: fold: check if multi-byte spaces are treated as blankCollin Funk1-13/+26
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
2025-09-04doc: update the md5/sha1 "weak hash" advisoryPádraig Brady1-2/+3
* doc/coreutils.texi: Adjust advisory for md5sum and sha1sum to include "sha3", and also the more general `cksum -a` interface.
2025-09-04tests: cksum: check more length variantsPádraig Brady2-23/+28
* tests/cksum/cksum-raw.sh: Adjust to non legacy naming, and also check various length variations. * tests/misc/read-errors.sh: Likewise.
2025-09-04doc: NEWS: expand on the fold multi-byte enhancementsPádraig Brady1-2/+3
* NEWS: Mention all of fold(1) got multi-byte enhancement, with -c being an ancillary part of that.
2025-09-04cksum: prefer -a sha2 -l ###, to -a sha###Pádraig Brady6-42/+88
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.
2025-09-03cksum: add support for SHA-3Collin Funk8-38/+219
* 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.
2025-09-03maint: avoid syntax-check failure from previous commitCollin Funk3-3/+0
* src/df.c: Don't include uchar.h. * src/ls.c: Likewise. * src/wc.c: Likewise.
2025-09-03fold: check that characters are not non-breaking spaces when -s is usedCollin Funk3-9/+17
NetBSD 10 and Solaris 11.4 treat non-breaking spaces as blank characters unlike glibc. * src/system.h: Include uchar.h. (c32isnbspace): New function based on iswnbspace from src/wc.c. * src/fold.c (fold_file): Use it. * src/wc.c (iswnbspace): Remove function. (maybe_c32isnbspace): New function. (wc, main): Use it. Fixes https://bugs.gnu.org/79300
2025-09-03maint: prefer issymlink to readlink with a small bufferCollin Funk5-11/+12
* bootstrap.conf (gnulib_modules): Add issymlink and issymlinkat. * src/copy.c: Include issymlink.h. (copy_reg): Use issymlink instead of readlinkat. * src/rmdir.c: Include issymlink.h. (main): Use issymlink instead of readlink. * src/tail.c: Include issymlink.h. (recheck, any_symlinks): Use issymlink instead of readlink. * src/test.c: Include issymlink.h. (unary_operator): Use issymlink instead of readlink.
2025-09-03build: update gnulib submodule to latestPaul Eggert1-0/+0
2025-09-03build: Update after gnulib changedBruno Haible1-2/+2
* gnulib-tests/Makefile.am: Move the AM_CFLAGS assignment before the 'include gnulib.mk'.
2025-09-02maint: avoid syntax-check failure from previous commitCollin Funk1-1/+1
* tests/seq/seq-long-double.sh: Place comma after "I.e.".
2025-09-02seq: be more accurate with large integer start valuesPádraig Brady3-4/+19
* src/seq.c (main): Avoid possibly innacurate conversion to long double, for all digit start values. * tests/seq/seq-long-double.sh: Add a test case. * NEWS: Mention the improvement. Fixes https://bugs.gnu.org/79369
2025-09-01df: pacify static analysisPaul Eggert1-9/+5
Problem reported by Yubiao Hu <https://bugs.gnu.org/79336>. * src/df.c (get_dev): Assume MOUNT_POINT is non-null.
2025-08-31ls: fix alignment with locale formatted --sizePádraig Brady3-6/+35
Fix allocated size alignment in locales with multi-byte grouping chars. Tested with: LC_ALL=sv_SE.utf8 ls --size --block-size=\'k * src/ls.c (print_file_name_and_frills): Don't rely on printf("%*s", width, string) to pad multi-byte strings appropriately. Instead work out the padding required and use: printf("%*s%s", padding, "", string) to pad multi-byte appropriately. * tests/ls/block-size.sh: Add a test case. * NEWS: Mention the bug fix. Fixes https://bugs.gnu.org/79347
2025-08-30b2sum: --length: fix upper bound checkPádraig Brady3-1/+17
* src/digest.c (main): Don't saturate -l to BLAKE2B_MAX_LEN, so that the subsequent bounds check is performed. * tests/cksum/b2sum.sh: Add a test case. * NEWS: Mention the fix introduced in commit v9.5-71-gf2c84fe63
2025-08-28fold: fix handling of invalid multi-byte charactersCollin Funk2-5/+23
* src/fold.c (fold_file): Continue the loop when we have buffered bytes but nothing left to read from the file. (adjust_column): Don't assume that the character is printable. * tests/fold/fold-characters.sh: Add a new test case. (bad_unicode): New function.
2025-08-27tests: fold: add tests for multi-byte widthPádraig Brady1-0/+22
* tests/fold/fold.pl: The i18n patch didn't actually test folding of multi-byte characters, so add tests for various multi-byte forms.
2025-08-27tests: fold: copy i18n patch testsPádraig Brady1-1/+33
* tests/fold/fold.pl: Copy tests from Fedora, removing copy & pasted logic that was extraneous to either the i18n patch or upstream.
2025-08-27tests: parameterize IO_BUFSIZEPádraig Brady2-1/+8
* src/getlimits.c (main): Output IO_BUFSIZE, useful for sizing data for tests. * tests/fold/fold-characters.sh: Use it rather than hardcoding.
2025-08-27build: fold: fix build failure with C99Pádraig Brady1-1/+2
GCC 10.2 gave the following error: "error: label at end of compound statement" * src/fold.c (fold_file): Add a ";" to avoid C2X specific syntax.
2025-08-26fold: don't truncate multibyte characters at the end of the bufferCollin Funk2-2/+41
* src/fold.c (fold_file): Replace invalid characters with the original byte read. Copy multibyte sequences that may not yet be read to the start of the buffer before reading more bytes. * tests/fold/fold-characters.sh: Add a test case.
2025-08-26tests: fold: consolidate all fold tests in tests/foldPádraig Brady3-2/+2
* tests/misc/fold.pl: Move from here to ... * tests/fold/fold.pl: ... here. * tests/local.mk: Adjust accordingly.
2025-08-26tests: fold: add a memory constraint testPádraig Brady1-0/+6
Enforcing this interface behavior is worthwhile irrespective of our current implementation, to ensure future or other implementations conform. * tests/fold/fold-characters.sh: Ensure the fold implementation uses bounded memory.
2025-08-24fold: use fread instead of getlineCollin Funk1-9/+7
* src/fold.c: Include ioblksize.h. (fold_file): Use two IO_BUFSIZE-sized buffers. Use fread instead of getline. Check for if we reached the end of file.
2025-08-24tests: nproc: fix false failure on some systemsPádraig Brady1-12/+74
* tests/nproc/nproc-quota.sh: Also simulate sched_getscheduler() as this will not be called on older or non linux, or may return ENOSYS on Alpine. Fixes https://bugs.gnu.org/79299