Move unlink of temp file to before fatal exit

Ensure temporary file is deleted only on failure. As written this would never be executed.
This commit is contained in:
Andy Warner
2026-09-21 03:51:24 -06:00
committed by GitHub
parent a7fc80d8c5
commit e79365ec61
+1 -1
View File
@@ -1275,9 +1275,9 @@ void autr_write_file(struct module_env* env, struct trust_anchor* tp)
FlushFileBuffers((HANDLE)_get_osfhandle(_fileno(out)));
#endif
if(fclose(out) != 0) {
unlink(tempf);
fatal_exit("could not complete write: %s: %s",
fname, strerror(errno));
unlink(tempf);
return;
}
/* success; overwrite actual file */