GNU bug report logs -
#75209
30.0.93; Emacs reader failed to read data in "/home/nlj/.cache/org-persist/gc-lock.eld"
Previous Next
Full log
Message #173 received at 75209 <at> debbugs.gnu.org (full text, mbox):
"N. Jackson" <njackson <at> posteo.net> writes:
>>> (let ((tmp-file-2 (make-temp-file "org-persist-")))
>>> ;; Just renaming may still not be atomic on Windows, so we do
>>> ;; a bit more complex juggle.
>>> (rename-file file tmp-file-2 'overwrite)
>>> (rename-file tmp-file file 'overwrite)
>>> (delete-file tmp-file-2)))
>>
>> Ouch. Not 'overwrite flag, but `make-temp-name' instead of `make-temp-file'.
>
> For tmp-file you are using make-temp-file and then you use
> 'overwrite. I suppose it's probably best if tmp-file-2 is handled
> similarly. (Unless there's a reason not to that I'm missing.)
The whole point (AFAIU) is that we do not want to overwrite the original
file; just move. `make-temp-file' won't work.
> Also, in the doc string:
>
> There is a race condition between calling `make-temp-name' and
> later creating the file, which opens all kinds of security holes.
> For that reason, you should normally use `make-temp-file' instead.
Not sure. AFAIU, the race condition is someone else create an actual
file in place of the generated file name. But we have no delay between
the operations here, so there is no difference.
That said, I have no preference about the best approach here.
The diff is just for testing.
--
Ihor Radchenko // yantar92,
Org mode maintainer,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
This bug report was last modified 3 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.