From 75fe81865fedf40b1252ec89533eeaaeaeae2aae Mon Sep 17 00:00:00 2001 From: Khawar Zamman Wani Date: Mon, 19 Oct 2026 14:23:45 +0530 Subject: [PATCH] CLI: say that the input-overwrite check guards against mistakes, not races The paths are compared before the save reopens the output, so a link swapped in meanwhile is not caught (CodeRabbit nitpick on #7455). Co-Authored-By: Claude Opus 5.5 --- apps/photocraft-cli/src/lib.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/photocraft-cli/src/lib.rs b/apps/photocraft-cli/src/lib.rs index 69bc1a9632..a9c6b5b5ea 100644 --- a/apps/photocraft-cli/src/lib.rs +++ b/apps/photocraft-cli/src/lib.rs @@ -244,7 +244,9 @@ fn automation_workspace(args: &Args) -> Result { /// An output that is the input file itself, however it is spelt (relative, with `./`, through a /// hard or symbolic link), would replace the original, and a lossy re-encode can't be undone: it /// is refused unless `--in-place` asks for it, as `batch` refuses an `--out` that is its `--in` -/// folder (#7437). +/// folder (#7437). The paths are compared when the command starts and the save opens `output` +/// again later, so another process swapping in a link meanwhile goes unnoticed: this guards +/// against mistakes, it is not a security boundary. fn refuse_overwriting_input(a: &Args, input: &str, output: &str) -> R { if !a.has("--in-place") && photocraft_engine::file_cmds::same_file(input, output) { return Err(format!("{output} is the input file, so the result would replace the original: choose another output, or pass --in-place to overwrite it"));