Repository navigation
Re-open the temporary file after editing - #64
Merged
Merged
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The reopened /tmp path must reject symlinks and validate the resulting file.
1 open finding
What changed in this PR
Reopens edited temporary files so inode-replacing editors produce updated descriptors.
Changes:
- Renames
open_editor()toedit_file(). - Reopens the temporary file after editing.
- Updates all callers to receive the new descriptor.
| File | Description |
|---|---|
src/itsa.c |
Adds post-edit reopening and updates editor call sites. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This is to handle cases where an editor *replaces* the file with the edited version where by the file will have a different inode. E.g., Before saving the edited file $ ls -l /proc/191852/fd/3 && grep ino /proc/191852/fdinfo/3 lrwx------ 1 andrew andrew 64 Oct 11 14:16 /proc/191852/fd/3 -> /tmp/.itsa_accounting_adjustments.jJxHVx.json ino: 44354 After saving $ ls -l /proc/191852/fd/3 && grep ino /proc/191852/fdinfo/3 lrwx------ 1 andrew andrew 64 Oct 11 14:16 /proc/191852/fd/3 -> /tmp/.itsa_accounting_adjustments.jJxHVx.json ino: 44583 So even though it's still the *same* file, it now has a different inode number. This renames the open_editor() fucntion to edit_file() as it now does this extra thing... Signed-off-by: Andrew Clayton <ac@sigsegv.uk>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

This is to handle cases where an editor replaces the file with the edited version where by the file will have a different inode. E.g.,
Before saving the edited file
$ ls -l /proc/191852/fd/3 && grep ino /proc/191852/fdinfo/3
lrwx------ 1 andrew andrew 64 Oct 11 14:16 /proc/191852/fd/3 -> /tmp/.itsa_accounting_adjustments.jJxHVx.json
ino: 44354
After saving
$ ls -l /proc/191852/fd/3 && grep ino /proc/191852/fdinfo/3
lrwx------ 1 andrew andrew 64 Oct 11 14:16 /proc/191852/fd/3 -> /tmp/.itsa_accounting_adjustments.jJxHVx.json
ino: 44583
So even though it's still the same file, it now has a different inode number.
This renames the open_editor() fucntion to edit_file() as it now does this extra thing...