On Thu, 17 Sep 2026 01:46:36 -0400 Daniel Colascione <[email protected]> wrote:
> Mario Domenech Goulart <[email protected]> writes: >> >> On Thu, 17 Sep 2026 00:13:19 -0400 Daniel Colascione via Chicken-users >> <[email protected]> wrote: >> >>> create-temporary-file generates a candidate filename, checks whether it >>> exists, and if it doesn't, opens the file in non-exclusive, write, and >>> truncate mode. This strategy creates a TOCTOU race and can result in the >>> calling process being tricked into truncating files or following >>> symlinks it shouldn't. The generated name has too little entropy to make >>> guessing infeasible. create-temporary-file should omit the existence >>> check and open the generated file using O_EXCL, retrying on EEXIST. >>> >>> Better yet would be to call mkstemp(3), which addresses these issues >>> and others. >>> >>> create-temporary-directory has a similar race, but because mkdir is >>> always exclusive, race failures cause spurious errors instead of >>> potentially unwanted file IO. It should retry on collision. >> >> Thanks for bringing this up. We have >> https://bugs.call-cc.org/ticket/tf5/f598bc17026468d3b75cbe36589b2f0321f72fa1/ >> for this issue > > It's been open for twelve years. What's involved in fixing it? A patch, basically. While in theory the current implementation is subject to TOCTOU issues, in practice nobody has complained about them so far. Since are pretty low on manpower, issues that do not cause real problems tend to be treated with less priority. [0] was an effort in the direction of addressing this issue, and the idea would be to use it to create temporary files/directories in a race-free manner, which was done in [1] for delete-file*. As simple as that change seemed to be, it ended up causing problems ([2], which, I have to admit, I don't quite understand why). [0] https://code.call-cc.org/githtml/chicken-core/master/commits/251e3ce628dcfa5d8a6bfa5b128f4cc4fb4c1b8b.html [1] https://code.call-cc.org/githtml/chicken-core/master/commits/47158a51b2d9c3d7dda97d3b88ade8fcddde220b.html [2] https://code.call-cc.org/githtml/chicken-core/master/commits/f6896cce8130bb758213c4b8483089c79fb029ca.html All the best. Mario -- https://parenteses.org/mario
