aboutsummaryrefslogtreecommitdiffstats
path: root/src (follow)
AgeCommit message (Collapse)AuthorFilesLines
2025-11-08chcon: fix memory leak in error pathPádraig Brady1-1/+4
* src/chcon.c (change_file_context): If compute_context_from_mask fails, free the previously allocated file_context. Fixes https://bugs.gnu.org/79780
2025-11-04maint: adjust lseek_copy to handle non zero offsetsPádraig Brady1-2/+2
* src/copy-file-data.c (lseek_copy): hole_start is initialized only when ext_start == ipos. (infer_scantype): Update the hole_start initialization to the more logically correct POS, even though that init is only needed to suppress a -Wmaybe-uninitialized warning. Note gcc 15.2 at least doesn't seem to need that suppression.
2025-11-03tests: date: check that write errors are promptly diagnosedCollin Funk1-0/+9
This improvement is due to changes to Gnulib's fprintftime module. * NEWS: Mention the improvement. * src/getlimits.c (OFF64_T_MAX, OFF64_T_MIN): New macros. (main): Print them. * tests/misc/write-errors.sh: Call getlimits_. Add a date invocation.
2025-11-03doc: squashfs issue to be squashed in Linux 6.18Paul Eggert1-2/+3
2025-11-03date: avoid a duplicated write error diagnoticPádraig Brady1-1/+2
* src/show-date.c (show_date): Only show the fprintftime() diagnostic if a further diagnostic will not be shown.
2025-11-03date: translate/clarify recent error messagePádraig Brady1-1/+1
* src/show-date.c (show_date): Flagged by syntax-check.
2025-11-03date: promptly diagnose write errors with --filePádraig Brady1-0/+3
* src/date.c (batch_convert): Check error state of stdout after each date is processed. * tests/misc/write-errors.sh: Add a test case.
2025-11-01date: diagnose fprintftime failurePaul Eggert1-6/+9
* src/show-date.c (show_date): Diagnose fprintftime failure, as it need not be an output error.
2025-11-01pr: improve nstrftime failure checkPaul Eggert1-5/+8
* src/pr.c (init_header): Do not report an nstrftime EOVERFLOW error as memory exhaustion. Instead, output the time as an integer. Also, work even if nstrftime (nullptr, SIZE_MAX, ...) would return PTRDIFF_MAX which means adding 1 would overflow..
2025-11-01ls: better nstrftime failure checkPaul Eggert1-5/+2
* src/ls.c (print_long_format): Streamline the checking for failure of nstrftime.
2025-11-01build: reduce explicit dependencies on macOS CoreFoundationPádraig Brady1-1/+1
* src/local.mk: Revert v9.7-322-gc2e1816a5, instead relying on the more focused v9.8-79-g532cd66af. When built with --disable-nls on macOS this will result in only some commands being linked with INTL_MACOSX_LIBS, thus resulting in env(1) at least not setting a __CF_USER_TEXT_ENCODING envirnoment variable.
2025-11-01build: fix macOS build without libintlGrisha Levit1-0/+10
A more precise fix than commit v9.7-322-gc2e1816a5 * configure.ac (USE_NLS): new AM_CONDITIONAL. * src/local.mk: add @INTL_MACOSX_LIBS@ to <prog>_LDADD that need it.
2025-11-01maint: ln: eliminate a clang -Wformat-extra-args warningBruno Haible1-12/+25
* src/ln.c (do_link): Don't pass unused arguments to error(). Don't use "%.0s" to consume a string argument without printing it.
2025-11-01maint: ls: adjust to gnulib nstrftime changesBruno Haible1-5/+7
* src/ls.c (align_nstrftime): Change return type to ptrdiff_t. (print_long_format): Treat a negative return value from align_nstrftime as failure.
2025-11-01copy: be more defensive/restrictive with posix_fadvisePádraig Brady1-8/+9
* src/copy-file-data.c (copy_file_data): Only give the POSIX_FADV_SEQUENTIAL hint when we _know_ we'll definitely use a read/write loop to copy the data. Also only apply the hint to the whole file, as we've seen OpenZFS at least special case that. (sparse_copy): Update stale comment.
2025-11-01copy: don't avoid copy-offload upon SEEK_HOLE indicating non-sparsePádraig Brady1-2/+9
* src/copy-file-data.c (infer_scantype): Fall back to a plain copy if SEEK_HOLE indicates non-sparse, as zero copy avoids copy offload. This was seen with transparently compressed files on OpenZFS. * tests/cp/sparse-perf.sh: Add a test case even though it might only trigger on compressed file systems that don't support reflink. * NEWS: Mention the bug fix. Addresses https://github.com/coreutils/coreutils/issues/122
2025-11-01copy: avoid posix_fadvise bypassing copy offload behaviorPádraig Brady1-2/+5
* src/copy-file-data.c (): pass 0 to posix_fadvise to indicate to EOF. coreutils 9.8 used OFF_T_MAX instead, which triggered OpenZFS 2.2.2 at least to synchronously (decompress and) populate the page cache. Addresses https://github.com/coreutils/coreutils/issues/122
2025-10-31timeout: use fork and execvp instead of posix_spawnCollin Funk1-24/+23
* NEWS: Remove timeout from the list of programs that use posix_spawn. * bootstrap.conf (gnulib_modules): Remove posix_spawnattr_setsigmask. * src/timeout.c: Don't include spawn.h. (main): Use fork and execvp instead of posix_spawn. This reverts commit dac96ce3e3a2424919fea6a17978b6e91e575d86.
2025-10-31sort: optimize the lookups of the --compress-programBruno Haible1-10/+20
* src/sort.c (get_resolved_compress_program): New function. (pipe_child): Use it instead of calling find_in_given_path each time.
2025-10-30maint: avoid syntax-check failure from previous commitCollin Funk1-2/+2
* src/sort.c (pipe_child): Use nullptr instead of NULL.
2025-10-30sort: consistently diagnose access issues to --compress-programBruno Haible1-3/+26
* bootstrap.conf (gnulib_modules): Add findprog-in. * src/sort.c: Include findprog.h. (pipe_child): Look up the compress_program in $PATH and report errors such as ENOENT or EACCES before invoking posix_spawnp. This avoids inconsistency on systems that emulate posix_spawn through fork/exec, as they would otherwise treat such a failure as a generic failure and fail the sort, rather than continuing without compression.
2025-10-29sort: fix silent exit upon SIGPIPE from --compress-programPádraig Brady1-38/+51
* src/sort.c (main): Ignore SIGPIPE so we've more control over how we handle for stdout and compression programs. (sort_die): Handle EPIPE from stdout and mimic a standard SIGPIPE, otherwise reverting to a standard exit(SORT_FAILURE); * tests/sort/sort-compress-proc.sh: Add a test case. * NEWS: Mention the bug fix.
2025-10-28numfmt: ensure fields don't split on nbspPádraig Brady1-1/+2
* src/numfmt.c (newline_or_blank): Explicitly ensure we don't match NBSP as on platforms like NetBSD 10 or Solaris 11, NBSP is considered a blank character. This should have been part of commit v9.8-39-g8bc11f80a Solaris 11 test failure reported by Bruno Haible.
2025-10-27maint: prefer FTS_ROOTLEVEL when checking the fts_level of an FTSENTCollin Funk3-4/+4
* src/chcon.c (process_file): Use FTS_ROOTLEVEL instead of 0. * src/chmod.c (process_file): Likewise. * src/chown-core.c (change_file_owner): Likewise.
2025-10-27timeout: use the more efficient posix_spawn to invoke the commandCollin Funk1-18/+24
* NEWS: Mention the improvement. Consolidate the posix_spawn improvements into one item. * bootstrap.conf (gnulib_modules): Add posix_spawnattr_setsigmask. * src/timeout.c: Include spawn.h. (main): Setup signals using a posix_spawnattr_t object. Use posix_spawn instead of fork and execvp.
2025-10-27maint: prefer ckd_add for overflow checksCollin Funk5-12/+6
* src/cksum.c (cksum_slice8, crc32b_sum_stream): Use ckd_add to check for overflow. * src/cksum_avx2.c (cksum_avx2): Likewise. * src/cksum_avx512.c (cksum_avx512): Likewise. * src/cksum_pclmul.c (cksum_pclmul): Likewise. * src/cksum_vmull.c (cksum_vmull): Likewise.
2025-10-25sort: use the more efficient posix_spawn to invoke --compress-programCollin Funk1-98/+113
* NEWS: Mention the improvement. Mention that 'sort' will continue without compressing temporary files if the program specified by --compress-program cannot be executed. * doc/coreutils.texi (sort invocation): Document the behavior when the program specified by --compress-program cannot be executed. * src/sort.c: Include spawn.h. (MAX_FORK_TRIES_COMPRESS, MAX_FORK_TRIES_DECOMPRESS): Remove definition. (MAX_TRIES_COMPRESS, MAX_TRIES_DECOMPRESS): New definitions based on MAX_FORK_TRIES_COMPRESS and MAX_FORK_TRIES_DECOMPRESS. (async_safe_die): Remove function. (posix_spawn_file_actions_move_fd): New function. (pipe_fork): Remove function. (pipe_child): New function based on pipe_fork. Return an error number instead of a pid. Use posix_spawnp instead of calling fork and expecting the caller to exec. (maybe_create_temp): Call pipe_child instead of pipe_fork. Print a warning to standard error if --compress-program cannot be executed and the error is different than the previous call. Remove code for the child process. (open_temp): Remove code for the child process. Improve error message. * tests/sort/sort-compress.sh: Add a test case for when the program specified by --compress-program does not exist.
2025-10-23maint: remove unnecessary ignore_value usageCollin Funk1-3/+2
* src/install.c: Remove ignore-value.h include. (strip): Don't use ignore_value on posix_spawnattr_destroy since it isn't declared with the warn_unused_result attribute. Pass the checked pointer to posix_spawnattr_destroy instead of the variable it points to.
2025-10-23install: enhance error diagnostic when running strip failsBernhard Voelker1-1/+7
* src/install.c (strip): Mention explicitly that the strip program failed in the case the user specified a custom strip program name.
2025-10-23split: cleanup after posix_spawnCollin Funk1-0/+3
* boostrap.conf (gnulib_modules): Add posix_spawn_file_actions_destroy. * src/split.c (cleanup): Call posix_spawnattr_destroy and posix_spawn_file_actions_destroy after a successful posix_spawn.
2025-10-23split: prefer posix_spawn to fork and execlCollin Funk1-37/+57
* NEWS: Mention the change. * bootstrap.conf (gnulib_modules): Add posix_spawn, posix_spawnattr_setsigdefault, posix_spawn_file_actions_addclose, posix_spawn_file_actions_adddup2, and posix_spawn_file_actions_init. * src/split.c: Include spawn.h. (create): Use posix_spawn instead of fork and execl.
2025-10-22pr: promptly diagnose write errorsPádraig Brady1-0/+6
* src/pr.c (print_page): Exit promptly for `yes | pr`. (print_clump): Exit promptly for `pr < /dev/zero`. * tests/misc/write-errors.sh: Enable test cases. * NEWS: Mention the improvement.
2025-10-22nl: promptly diagnose write errorsPádraig Brady1-0/+3
* NEWS: Mention the improvement. * src/nl.c (process_file): Exit if error outputting line. * tests/misc/write-errors.sh: Enable the test case.
2025-10-22fmt: promptly diagnose write errorsPádraig Brady1-1/+7
* NEWS: Mention the improvement. * src/fmt.c (put_line): Exit if any error writing line. (flush_paragraph): Exit if any error writing buffer. * tests/misc/write-errors.sh: Enable the (flush_paragraph) test case, and add another to check the put_line() case.
2025-10-22numfmt: promptly diagnose write errorsPádraig Brady1-1/+7
* src/numfmt.c (process line): Inspect the stdio error state when outputting each line so that we don't have to check each output function but do eventually exit upon write error, while also remaining buffered. (main): Also check when outputting a header for the edge case of very long headers. * tests/misc/write-errors.sh: Enable the numfmt test case. * NEWS: Mention the improvement, and reorganize all numfmt improvements.
2025-10-21install: prefer posix_spawnp to fork and execlpCollin Funk1-19/+37
* NEWS: Mention the change. * bootstrap.conf (gnulib_modules): Add posix_spawnattr_destroy, posix_spawnattr_init, posix_spawnattr_setflags, and posix_spawnp. * src/install.c (strip): Use posix_spawnp instead of fork and execlp.
2025-10-20numfmt: optimize multi-byte --delimiter searchPádraig Brady1-1/+31
* src/numfmt.c (is_utf8_charset): A new function to efficiently determine if running with a UTF-8 charset. (mbsmbchr): A new function to efficiently search for a (multi-byte) character in a multi-byte string. (next-field): Use mbsmbchr() rather than mbstr() directly.
2025-10-20numfmt: support multi-byte --delimiterPádraig Brady1-22/+24
* bootstrap.conf: Depend on mbsstr() to robustly search for a multi-byte delimiter character (string) within a multi-byte string. * src/numfmt.c (main): Accept a valid multi-byte delimiter character. (next_field): Adjust delimiter search from single byte to multi-byte aware. Use mbsstr to find the first match. * tests/misc/numfmt.pl: Add test case. * NEWS: Mention the improvement.
2025-10-18numfmt: use multi-byte aware suffix matchingPádraig Brady1-6/+3
* src/numfmt.c (process_suffixed_number): Use gnulib's mbs_endswith() helper, which is more robust in non UTF-8 locales. Also always output a devmsg if a suffix is specified.
2025-10-18numfmt: fix issues with multi-byte blanksPádraig Brady1-8/+20
* src/numfmt.c (process_line): Restore byte overwritten with NUL, as it may be part of a multi-byte blank. (process_suffixed_number): Skip multi-byte blanks, and correctly determine width with mbswidth(). (parse_format_string): Use c_isblank() to explicitly indicate that's all the format spec supports. * tests/misc/numfmt.pl: Add test cases. * NEWS: Mention the bug fix.
2025-10-17numfmt: add --unit-separatorPádraig Brady1-7/+37
Output, accept, or disallow a string between the number and unit as recommended in <https://physics.nist.gov/cuu/Units/checklist.html> I.e. support outputting numbers of the form: "1234 M" * src/numfmt.c (simple_strtod_human): Skip unit separator if present, or disallow a unit separator if empty. (double_to_human): Output unit separator if specified. (main): Accept --unit-separator. * tests/misc/numfmt.pl: Add test cases. * doc/coreutils.texi: Describe the new option, giving examples of interaction with --delimiter. * NEWS: Mention the new feature. * THANKS.in: Add Johannes Schauer Marin Rodrigues, who provided a preliminary patch.
2025-10-17numfmt: support reading numbers with grouping charactersPádraig Brady1-1/+13
This does not validate grouping character placement, and currently just ignores grouping characters. * src/numfmt.c (simple_strtod_int): Skip grouping chars that are part of a number. * tests/misc/numfmt.pl: Add test cases. * NEWS: Mention the improvement.
2025-10-17numfmt: support reading numbers with NBSP before unitPádraig Brady1-10/+21
* src/numfmt.c (simple_strtod_human): Accept (multi-byte) non-breaking space character between number and unit. Note we restrict this to a single character between number and unit, to allow less ambiguous parsing if multiple blanks are used to delimit fields. * tests/misc/numfmt.pl: Add test cases. * doc/coreutils.texi (numfmt invocation): Fix stale description --delimiter skipping whitespace. * NEWS: Mention the improvement.
2025-10-11numfmt: fix buffer over-read (CWE-126)Pádraig Brady1-3/+8
* src/numfmt.c (simple_strtod_human): Check for NULL after pointer adjustment to avoid Out-of-range pointer offset (CWE-823). * NEWS: Mention the fix.
2025-10-07maint: cksum: document a base64/hex parsing ambiguity with untaggedPádraig Brady1-1/+12
* src/digest.c (split_3): Mention the ambiguity in misinterpreting base64 characters as hex is not a practical consideration. Also add an example of both tagged formats which makes it easier to interpret the parsing logic.
2025-10-07cksum: fix --check with untagged base64 format with tag matchesPádraig Brady1-22/+25
* src/digest.c (split_3): Fallback to untagged matching in the case where -a is specified and we have matched a TAG in the possibly base64 data. This might happen in 1 in every 64K files. Note we remove the modification of string S (and redundant streq) in the tag matching, as that was not needed since v8.32-223-g217cd278e. * tests/cksum/cksum-c.sh: Add a test case. * NEWS: Mention the bug fix.
2025-10-07cksum: fix length validation with SHA2- tagged formatPádraig Brady1-7/+8
* src/digest.c (sha2_sum_stream): Change from unreachable() to affirm() so that we have defined behavior unless we configure with --disable-assert. (sha3_sum_stream): Likewise. (split_3): Validate SHA2-lengths before passing on. * tests/cksum/cksum-c.sh: Add a test case. * NEWS: Mention the bug fix.
2025-10-07cksum: fix --check with --algorithm=sha2Pádraig Brady1-2/+6
* src/digest.c (split_3): Look up the provided tag with -a sha2 because there is not a 1:1 mapping between them. * tests/cksum/cksum-c.sh: Add a test case. * NEWS: Mention the bug fix.
2025-10-06rm: remove redundant mark_ancestor_dirs callPaul Eggert1-1/+0
* src/remove.c (rm_fts): Remove unnecessary call. Since this code is executed only when not recursive, there are no ancestors to mark.
2025-10-06rm: make ‘rm -d DIR’ more like ‘rmdir DIR’Paul Eggert1-10/+8
* src/remove.c (rm_fts): When not recursive, arrange for ‘rm -d DIR’ to behave more like ‘rmdir DIR’. This works better for Ceph snapshot directories. Problem reported by Yannick Le Pennec (bug#78245).