fix(safety): make the rollback temp path collision-resistant

Open Beginner friendly
#4 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
rust

Research direction

Locate the rollback temp-file creation and read how its PID-based name and File::create call are used. Change the name and creation behavior as suggested, then verify that collisions fail rather than truncate and that rollback snapshots remain usable after compression failure.

Written by the indexing model from the issue text.

Description

The rollback temp file is named from the PID alone and created with File::create, which truncates an existing file. Two failure modes follow:

  1. A stale temp left by a crashed process with the same PID is silently truncated and reused.
  2. Two concurrent rollbacks in the same process share one path and race, so one can overwrite the other's snapshot.

Both matter because this file is the rollback snapshot — the copy used to restore the original after a failed compression. Losing it turns a recoverable failure into a corrupted file.

A fork of this engine in abitious named the temp with PID + nanos + a counter and created it with create_new (O_EXCL), so a collision fails loudly instead of truncating. That fork is now deleted in favor of depending on this crate, so the hardening is lost unless it lands here.

Suggested fix: add nanos and a process-local counter to the name, and switch File::create to OpenOptions::new().create_new(true).

Dominant language
TypeScript
Stars
1
Forks
1
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from SocketDev/decmpfs

All issues in SocketDev/decmpfs

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.