Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linkchecker: fix panic on directory symlinks #93897

Merged
merged 1 commit into from
Feb 12, 2022
Merged

linkchecker: fix panic on directory symlinks #93897

merged 1 commit into from
Feb 12, 2022

Conversation

schopin-pro
Copy link
Contributor

In Debian and Ubuntu, there are some patches that change the rustc/fonts
directory to a symlink to the system fonts. This triggers a latent bug
in linkchecker, as the DirEntry filetype isn't a dir but later on the
file itself, when opened, is one, triggering an unreachable!() clause.

This patch fixes the situation by using std::fs::metadata, which goes
through symlinks.

I'd have added a test case but tidy doesn't seem to like symlinks, and
moreover I'm not sure how Git deals with symlinks on Windows.

Signed-off-by: Simon Chopin simon.chopin@canonical.com

In Debian and Ubuntu, there are some patches that change the rustc/fonts
directory to a symlink to the system fonts. This triggers a latent bug
in linkchecker, as the DirEntry filetype isn't a dir but later on the
file itself, when opened, is one, triggering an unreachable!() clause.

This patch fixes the situation by using std::fs::metadata, which goes
through symlinks.

I'd have added a test case but `tidy` doesn't seem to like symlinks, and
moreover I'm not sure how Git deals with symlinks on Windows.

Signed-off-by: Simon Chopin <simon.chopin@canonical.com>
@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Mark-Simulacrum (or someone else) soon.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 11, 2022
@the8472
Copy link
Member

the8472 commented Feb 11, 2022

I'd have added a test case but tidy doesn't seem to like symlinks, and moreover I'm not sure how Git deals with symlinks on Windows.

You could generate the testcase at test-time in a temporary directory. And bail out if symlinks aren't supported.

@Mark-Simulacrum
Copy link
Member

I'm not convinced a test case is necessary, particularly when we ourselves don't really use this functionality. linkcheck isn't a stability deliverable.

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Feb 11, 2022

📌 Commit 3a1ffea has been approved by Mark-Simulacrum

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 11, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 12, 2022
…Mark-Simulacrum

linkchecker: fix panic on directory symlinks

In Debian and Ubuntu, there are some patches that change the rustc/fonts
directory to a symlink to the system fonts. This triggers a latent bug
in linkchecker, as the DirEntry filetype isn't a dir but later on the
file itself, when opened, is one, triggering an unreachable!() clause.

This patch fixes the situation by using std::fs::metadata, which goes
through symlinks.

I'd have added a test case but `tidy` doesn't seem to like symlinks, and
moreover I'm not sure how Git deals with symlinks on Windows.

Signed-off-by: Simon Chopin <simon.chopin@canonical.com>
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 12, 2022
…Mark-Simulacrum

linkchecker: fix panic on directory symlinks

In Debian and Ubuntu, there are some patches that change the rustc/fonts
directory to a symlink to the system fonts. This triggers a latent bug
in linkchecker, as the DirEntry filetype isn't a dir but later on the
file itself, when opened, is one, triggering an unreachable!() clause.

This patch fixes the situation by using std::fs::metadata, which goes
through symlinks.

I'd have added a test case but `tidy` doesn't seem to like symlinks, and
moreover I'm not sure how Git deals with symlinks on Windows.

Signed-off-by: Simon Chopin <simon.chopin@canonical.com>
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 12, 2022
…askrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#91908 (Add 2 tests)
 - rust-lang#93595 (fix ICE when parsing lifetime as function argument)
 - rust-lang#93757 (Add some known GAT bugs as tests)
 - rust-lang#93759 (Pretty print ItemKind::Use in rustfmt style)
 - rust-lang#93897 (linkchecker: fix panic on directory symlinks)
 - rust-lang#93898 (tidy: Extend error code check)
 - rust-lang#93928 (Add missing release notes for rust-lang#85200)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 475b45f into rust-lang:master Feb 12, 2022
@rustbot rustbot added this to the 1.60.0 milestone Feb 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants