Check trusted XMP temporary paths on Windows

This commit is contained in:
Codex committed 2026-12-01 16:34:11 +01:00
1 parent f37b5811ad
commit 2a66d0fe6b
1 file changed
+2 -2
+2 -2
View File
@@ -2027,7 +2027,7 @@ fn xmp_write(host: &Host, a: &[Data]) -> Result<Data, HostError> {
let name = target.file_name().map(|n| n.to_string_lossy().into_owned()).unwrap_or_default();
let temp_name = |n: u32| target.with_file_name(format!(".{name}.{}.{n}.tmp", std::process::id()));
let first = temp_name(0);
let temp_allowed = disk.target(&first.to_string_lossy(), false).is_ok_and(|t| t == first);
let temp_allowed = disk.target(&shown(&first), false).is_ok_and(|t| t == first);
// A safe update writes only through a temporary file.
if safely && !temp_allowed {
return Ok(error(WRITE_FAILED));
@@ -2040,7 +2040,7 @@ fn xmp_write(host: &Host, a: &[Data]) -> Result<Data, HostError> {
// The temporary file takes a name no file or link has, so only the sidecar is replaced; when
// none of the names is free the sidecar is left as it is.
// Each name is checked against the places the run may write before it is made.
let allowed = |t: &Path| disk.target(&t.to_string_lossy(), false).is_ok_and(|r| r == t);
let allowed = |t: &Path| disk.target(&shown(t), false).is_ok_and(|r| r == t);
let new_file = |t: &Path| {
let mut options = std::fs::OpenOptions::new();
options.write(true).create_new(true);