Commit Graph
5569 Commits
Author SHA1 Message Date
hlsxx 2092e814db expr(fix): capacity overflow 2026-09-19 00:13:15 +02:00
Sylvestre Ledru 563e5c3d3f cp: clear setuid/setgid on directories created by cp -r 2026-09-19 00:08:54 +02:00
nagendramohan 5e9ccecf7e cp: apply the umask to directories created by cp -r
Without a preserve flag, cp -r gave every directory it created the
source's mode unmasked, so a 777 source directory became 777 regardless
of the umask, while regular files in the same copy were masked correctly.

The final permission pass defaulted a freshly-created directory to
preserving the source mode. Apply the umask in that defaulted case, as
GNU does, while a real preserve (-p/-a) and --no-preserve=mode are
unchanged.

Fixes #14549

Signed-off-by: nagendramohan <nagendramohan1990@gmail.com>
2026-09-19 00:08:54 +02:00
Piotr Kubaj 48429c09b9 tests/od: fix two tests on big-endian hosts
test_suppress_duplicates and test_od_options_after_filename dump
multi-byte units (-x, -O, -t x2) and compare the result against
little-endian expected output without selecting a byte order. They
fail on big-endian hosts, where od correctly defaults to the native
order:

  expected: " 1c68 fdbb\n"
  actual:   " 681c bbfd\n"

Pass --endian=little like the other tests in this file do. In
test_od_options_after_filename the option goes after the file name, in
keeping with what that test exercises.

Found on FreeBSD/powerpc64.
2026-09-18 21:06:20 +02:00
Darshil Patel 58bc4faac9 date: echo invalid input verbatim instead of as a Fluent number
translate! hands Fluent a number whenever the argument parses as one,
so the error for -d 1e9 showed '1000000000', -d -0 showed '0', and
-d 9. showed '9'. Use translate_text! for the invalid-date and
missing-plus messages, which echo what the user typed.

Fixes #14669. Fixes #14670.
2026-09-18 19:53:49 +02:00
xtqqczze 81a5ea6b63 chore: add missing newlines around spell-checker header 2026-09-18 17:07:39 +02:00
wtcpython b60091b73f tests: replace rlimit dependency with rustix::process 2026-09-18 12:44:34 +02:00
Daniel Hofstetter c7d7c0bde9 chore: remove empty comment lines from header 2026-09-18 10:32:33 +02:00
Daniel Hofstetter ddb03ce968 chore: add missing newlines to source header 2026-09-18 10:32:33 +02:00
weili 851b88530e tail: normalise a zero count in the obsolete operand parser
`from_obsolete_args` built `Signum::Positive(args.num)` unconditionally, while
`parse_num` — behind `-n +N` / `-c +N` — maps zero to `PlusZero`. So `+0`,
`+00`, `+0c` and `+0l` produced `Positive(0)`, which misses `unbounded_tail`'s
`PlusZero | Positive(1)` arms and underflows at `*count - 1`. Release wrapped
to `u64::MAX` and printed nothing, exiting 0 where GNU prints the whole input;
overflow-checks aborted. `bounded_tail` guards with `count > &1`, so only stdin
or a file at or below the block size is affected.

Obsolete `-0`/`-0c` now give `MinusZero` like `-n 0`, taking the existing
`-[nc]0` early exit: `tail -0 <missing>` exits 0 silently instead of 1,
matching GNU.

Fixes #14660
2026-09-18 10:16:21 +02:00
Devel 7b48d38fe0 date: add test_date_allow_missing_year and test_date_allow_spaces_after_month 2026-09-18 09:34:10 +02:00
xtqqczze 0c2d5fcd53 tests: avoid xattr for unsupported platforms 2026-09-18 07:57:43 +02:00
Alessio Attilio b2480b2f0a env: remove the --file extension 2026-09-17 14:58:27 +02:00
Daniel Hofstetter c296d55c9a ln: disable test on wasi (#14639) 2026-09-17 11:35:07 +02:00
pepsi zandChad Brewbaker 22d61c385e sort: write empty file when input is empty (#11958)
* adds implementations for this behavior in both threaded and wasi

* adds test for this behavior

Co-authored-by: Chad Brewbaker <crb002@gmail.com>
2026-09-17 08:58:53 +02:00
Sylvestre Ledru 4bf2727b49 generalize some mv code for ln, cp (#14623)
* generalize the mv code for ln, cp
replace links atomically instead of unlinking first

Forced replacement was unlink(dst) then create. The gap lets another user
claim dst in a directory they can write to -- including a name the sticky
bit forbids them to remove -- so a privileged ln hands them a trusted name.

* ln: don't leave the temp behind when the rename is a no-op

Renaming the temp onto a destination that is already a link to the same
inode does nothing and returns success, so the temp name survived:
`ln -f a b` with b already hard-linked to a left a stray Cu* file.

Unlink the temp after the rename either way; on the normal path it is
already gone.
2026-09-17 00:11:18 +02:00
Sylvestre Ledru 32adc589e3 cp: --attributes-only must give the destination the source's type (#14622)
It created a regular file whatever the source was, so a FIFO got the wrong
type and then blocked forever in File::open(source) during the xattr copy.

Dispatch on the source's type via the existing copy_fifo/copy_socket/copy_node
helpers, and require a regular source before using the fd-based xattr path.
Matches GNU for -a, -R --attributes-only and -a --attributes-only.
2026-09-16 23:59:26 +02:00
Javan ebcdac14e2 uucore: reject over-length BLAKE2b digests when checking (#14508)
When verifying a checksum file, the BLAKE2b output length was inferred
from the digest found in the file and handed to the hasher unchecked. A
digest longer than the 64 bytes BLAKE2b maximum made blake2b_simd fail
its own length assertion and abort the process, instead of the line
being reported as malformed.

Route that inferred length through parse_blake_length, like the --length
and tagged-line paths already do, and treat a rejected length as an
improperly formatted line. This matches GNU, which skips such a line and
exits 1 with "no properly formatted checksum lines found".

HashLength::from_bytes loses its last caller with this change, so drop
it.

Fixes #14487
2026-09-16 23:23:01 +02:00
Sylvestre Ledru d95cdb605a ls: report stat() failures on directory entries (GHSA-fhfr-qj69-pq5m) (#14553)
When stat() failed on an entry coming from read_dir(), PathData::metadata()
discarded the error: `ls -l` printed the unknown-metadata row, wrote nothing
to stderr and exited 0. GNU prints a diagnostic and exits 1.

Route the cached DirEntry metadata through the same error handling as the
non-cached path, so the failure is reported and the exit status is set.

While at it:
- do not print a second diagnostic when readlink() fails for an entry whose
  metadata could not be read either; GNU prints only one.
- stat() failures are reported as "cannot access X: Permission denied", the
  GNU wording, instead of "cannot open file X: Permission denied" (that
  message was only ever reachable from stat()/readlink() failures).

Reported by Hongkai Chen of SEFCOM Lab at Arizona State University.
2026-09-16 23:18:17 +02:00
Sylvestre Ledru baa8f7ab4f sort: create temporary files with mode 0600 instead of the umask 2026-09-16 23:09:13 +02:00
Sylvestre Ledru 4acc97ffc8 sort: report a failure to truncate the -o output file 2026-09-16 22:55:30 +02:00
Sylvestre Ledru 017fd1340b rm: fix segfault on very deeply nested directories (#14554)
safe_remove_dir_recursive_impl recursed once per directory level, so
`rm -rf` on a hierarchy tens of thousands of levels deep overflowed the
stack and died with SIGSEGV, leaving the tree in place.

Walk the tree with an explicit stack instead. Only the deepest 16 levels
keep their directory descriptor open; the others get theirs back through
".." on the way up, checked against the recorded device and inode so a
directory swapped in mid-walk cannot redirect the removal. Depth is then
bounded by memory rather than by the stack or the descriptor limit.

Keep the current path in one byte buffer, stepping into an entry and back
out by appending and truncating rather than building a fresh PathBuf per
entry, which a long path makes expensive. That is 7% fewer instructions
than the recursive version on the rm_recursive_tree benchmark.

Ask whether a directory is empty through its parent's descriptor too. The
path-based check fails past PATH_MAX and a failure counts as non-empty,
so `rm -ri` prompted before descending into an empty directory that deep,
and left it behind when the prompt was declined.

https://bugs.launchpad.net/bugs/2167206
https://github.com/uutils/coreutils/issues/2949
2026-09-16 15:38:13 +02:00
Nihal Ajayakumar b990ce7f1b link: add tests for zero args and existing destination (#11119)
* link: add tests for zero args and existing destination

* link: fix rustfmt formatting for test_link_dest_exists

Split the chained method call onto separate lines to match rustfmt's
expected formatting.

* link: fix test_link_dest_exists for cross-platform error message

The EEXIST error message varies by OS: Linux/macOS reports "File exists"
while OpenBSD reports "Already exists". Broaden the match to "exists"
to cover all platforms.

* link: fix test_link_no_arguments and rustfmt on test_link_dest_exists

- test_link_no_arguments: clap emits "the following required arguments
  were not provided" (not "2 values required") when zero args are
  given; drop the stderr assertion and keep only .fails().
- test_link_dest_exists: collapse the method chain to one line to
  satisfy rustfmt.
2026-09-16 14:15:44 +02:00
nagendramohan c6b9e4f092 ln: keep the destination when a forced link fails
`ln -f A B` unlinked B before attempting the link, so a link that failed
for any reason other than the destination already existing (a missing
source, a directory source, a dangling symlink with -L) left B deleted.

Attempt the link first and remove an existing destination only after the
link reports EEXIST, matching GNU, so a failed link never destroys the
destination.

Fixes #14550

Signed-off-by: nagendramohan <nagendramohan1990@gmail.com>
2026-09-15 09:42:58 +02:00
xtqqczze 5dbba49d50 chore: add missing newlines around spell-checker header 2026-09-15 09:04:19 +02:00