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

Don't try to open non-regular files #10726

Closed
mo8it opened this issue May 10, 2024 · 4 comments
Closed

Don't try to open non-regular files #10726

mo8it opened this issue May 10, 2024 · 4 comments
Labels
A-helix-term Area: Helix term improvements C-bug Category: This is a bug

Comments

@mo8it
Copy link
Contributor

mo8it commented May 10, 2024

Summary

Helix should only open regular files. Non regular files like devices and pipes should be rejected.

This can be fixed by checking FileType::is_file.

I can open a PR to fix it :)

Reproduction Steps

The following command will freeze and continuously eat RAM.

hx /dev/random

The following command just freezes:

mkfifo pipe
hx pipe

Platform

Relevant on Unix but probably also on Windows

Helix Version

helix 24.3 (f656b4f)

@mo8it mo8it added the C-bug Category: This is a bug label May 10, 2024
@pascalkuthe
Copy link
Member

pascalkuthe commented May 10, 2024

That seems mostly correct and match vim but symlinks should still be opened if they point qt a file or directory. Not sure how is_file handles those

@mo8it
Copy link
Contributor Author

mo8it commented May 10, 2024

fs::metadata traverses symlinks so is_file would return true.

The weird thing is that not every method returning Metadata traverses symlinks. One needs to read its docs. For example, DirEntry::metadata does NOT traverse symlinks.

@dead10ck
Copy link
Member

My first thought was "why?" but yeah, the more I think about it, apart from symlinks that point to regular files or directories, I can't think of a use case where any other file type makes sense. Editing a pipe, character device, block device, etc just doesn't make any sense. We need to be able to read the whole file and write back to it, and no other file type fits this pattern.

@krish-r
Copy link
Contributor

krish-r commented Jul 14, 2024

I believe this can be closed now since #10733 is merged.

(Off-topic: Congratulations on Rustlings rewrite :))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements C-bug Category: This is a bug
Projects
None yet
Development

No branches or pull requests

6 participants