Skip to content

fix(realpath): To error out in long paths#13223

Open
HackingRepo wants to merge 12 commits into
uutils:mainfrom
HackingRepo:patch-3
Open

fix(realpath): To error out in long paths#13223
HackingRepo wants to merge 12 commits into
uutils:mainfrom
HackingRepo:patch-3

Conversation

@HackingRepo

@HackingRepo HackingRepo commented Jun 30, 2026

Copy link
Copy Markdown

Fixes #13154
Fixes #13224

@HackingRepo HackingRepo changed the title Enhance error handling for file name length, to match gnu fix(realpath): To error out in long paths Jun 30, 2026
Comment thread src/uu/realpath/src/realpath.rs Outdated
if path_str.ends_with("/.") || path_str.ends_with("/./") {
abs.metadata()?; // raise no such file or directory error
for component in p.components() {
if let Some(name) = component.as_os_str().to_str() {

This comment was marked as resolved.

This comment was marked as resolved.

@HackingRepo HackingRepo requested a review from oech3 June 30, 2026 07:08
@HackingRepo

Copy link
Copy Markdown
Author

@sylvestre review that

@oech3

oech3 commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Does this fix #13224 too?

@sylvestre

Copy link
Copy Markdown
Contributor

@sylvestre review that

I would appreciate a more polite message
I am not a bot or an AI

@HackingRepo

Copy link
Copy Markdown
Author

oh sorry, yes you are right, we need talk in a polite manner, since we are humans

Comment thread src/uu/realpath/src/realpath.rs Outdated
@sylvestre

Copy link
Copy Markdown
Contributor

also, please ping me only when the testsuite is green and there are tests

@codspeed-hq

codspeed-hq Bot commented Jun 30, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 327 untouched benchmarks
⏩ 46 skipped benchmarks1


Comparing HackingRepo:patch-3 (82d8d64) with main (77933ae)

Open in CodSpeed

Footnotes

  1. 46 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@github-actions

github-actions Bot commented Jun 30, 2026

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/misc/io-errors (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/retry (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/symlink (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/cut/bounded-memory (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/date/date-locale-hour (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/rm/isatty (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/tail/pid-pipe (passes in this run but fails in the 'main' branch)
Note: The gnu test tests/dd/no-allocate is now being skipped but was previously passing.
Congrats! The gnu test tests/cp/link-heap is now passing!

@HackingRepo HackingRepo requested a review from sylvestre June 30, 2026 07:57
@HackingRepo

Copy link
Copy Markdown
Author

Hi, @sylvestre

now all tests passed and added tests and fix working, can you merge? i appreciate it or still

const OPT_RELATIVE_TO: &str = "relative-to";
const OPT_RELATIVE_BASE: &str = "relative-base";

const MAX_PATH: usize = 255;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems low, no ?

@HackingRepo HackingRepo Jun 30, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no

Comment thread tests/by-util/test_realpath.rs
@HackingRepo HackingRepo requested a review from sylvestre June 30, 2026 10:45
@HackingRepo

Copy link
Copy Markdown
Author

after i restore the tests, they failing that was weird, i just added the max limit then failed, i will see why

@HackingRepo

Copy link
Copy Markdown
Author

the openbsd test failing because

error: extern location for proc_macro2 does not exist: /home/runner/work/coreutils/coreutils/target/debug/deps/libproc_macro2-24e159babf15897f.rlib
 --> /home/tester/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/yoke-derive-0.8.2/src/lifetimes.rs:5:5
  |
5 | use proc_macro2::Span;
  |     ^^^^^^^^^^^

error[E0463]: can't find crate for `syn`
 --> /home/tester/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/yoke-derive-0.8.2/src/lifetimes.rs:6:5
  |
6 | use syn::ext::IdentExt as _;
  |     ^^^ can't find crate

error: extern location for quote does not exist: /home/runner/work/coreutils/coreutils/target/debug/deps/libquote-c6c049b8eedf5bdc.rlib
  --> /home/tester/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/yoke-derive-0.8.2/src/lib.rs:25:5
   |
25 | use quote::quote;
   |     ^^^^^

error[E0463]: can't find crate for `synstructure`
  --> /home/tester/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/yoke-derive-0.8.2/src/lib.rs:29:5
   |
29 | use synstructure::Structure;
   |     ^^^^^^^^^^^^ can't find crate

about soomething different not about realpath at all, it causing issues

@HackingRepo

HackingRepo commented Jun 30, 2026

Copy link
Copy Markdown
Author

the 1 failing last job, is about install unrelated fully to the pr, realpath is the thing we fixed, not install that just some problems occurs with CI/CD sometimes, ci/cd race issues sometime tests successed, however the important tests passed and only 1 job failing that happen in tons of prs. but however only 1 failing not a huge problem

@HackingRepo

HackingRepo commented Jul 1, 2026

Copy link
Copy Markdown
Author

Hi, @sylvestre

i appreciate it, when you have time, can you please review it again all tests passes, the 1 failing is unrelated to the pr and restored previous tests and ignored rsplit to cspell not fails and now passed, can you review and merge?

Comment thread src/uu/realpath/src/realpath.rs Outdated
.to_str()
.is_some_and(|name| name.len() > MAX_PATH)
}) {
return Err(Error::new(ErrorKind::InvalidInput, "File name too long"));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use the translate! macro here

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok i will do

@HackingRepo HackingRepo requested a review from sylvestre July 1, 2026 17:14
@HackingRepo

Copy link
Copy Markdown
Author

hi, @sylvestre review now. i added translate! no breaking change, or logic change, so what do you think, i appreciate it, when having time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

realpath /bin/ls $(python3 -c 'print("A"*256)') /bin/ls succeeds bug(realpath): when a filename larger it do not error out

3 participants