Skip to content

fix: only read regular files when previewing paths - #2643

Closed
jprx wants to merge 1 commit into
saghen:v1from
jprx:v1
Closed

jprx wants to merge 1 commit into
saghen:v1from
jprx:v1

Conversation

@jprx

@jprx jprx commented Sep 27, 2026

Copy link
Copy Markdown

Path previews can attempt to read from non-regular files, such as character devices, which can have unintended side effects. This can happen by just typing a device's absolute path without even requesting a preview.

For example, if you type /dev/uart.debug-console into a text file on macOS, the debug console device will be opened, and a non-blocking read will begin that never terminates. This results in neovim freezing when the user tries to quit, as the character device never completes reading.

To avoid opening character devices or other non-regular files which may have side effects, we first check that the file's type is actually a regular file before trying to read from it.

Path previews can attempt to read from non-regular files, such as
character devices, which can have unintended side effects. This can
happen by just typing a device's absolute path without even requesting a
preview.

For example, if you type /dev/uart.debug-console into a text file on
macOS, the debug console device will be opened, and a non-blocking read
will begin that never terminates. This results in neovim freezing when
the user tries to quit, as the character device never completes reading.

To avoid opening character devices or other non-regular files which may
have side effects, we first check that the file's type is actually a
regular file before trying to read from it.
@jprx

jprx commented Sep 27, 2026

Copy link
Copy Markdown
Author

Actually, I thought about this some more and we should call fstat before trying to open the file, not after. Will fix and submit new PR

@jprx jprx closed this Sep 27, 2026
@jprx
jprx deleted the v1 branch September 27, 2026 14:24
@jprx

jprx commented Sep 27, 2026

Copy link
Copy Markdown
Author

See #2644 for updated PR

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.

1 participant