Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I think you misunderstood the article. That section is not talking about actual pointers. Filenames are like pointers, opening a file is like dereferencing the filename to get the actual file. Any other process could "free your pointer" (by deleting the file) at any point in time. That's true no matter which language you use.


>Any other process could "free your pointer" (by deleting the file) at any point in time.

Files are garbage collected. There is no use after free if someone deletes your file because the OS sees that you are still using it


Yeah, common confusion to be out of free space, rm some huge file, and still be out of space because something has the file open.


There's a TOCTTOU going from the filename to the file handle, but once you have a handle,

- on Windows, another process deleting the file is prevented (unless you explicitly opted-in to cooperative FILE_SHARE_DELETE); and

- on Linux, another process deleting the file only unlinks its name, and your handle continues working with the nameless file and its content




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: