The trouble with symbolic links
The trouble with symbolic links
Posted Jul 12, 2022 3:26 UTC (Tue) by neilbrown (subscriber, #359)In reply to: The trouble with symbolic links by ma4ris5
Parent article: The trouble with symbolic links
> Here is one conceptual way to _open up a file for read_ in a safe way
Or you could use realpath() to expand all the symlinks, validate the path in whatever way you care about, and then use openat2() with RESOLVE_NO_SYMLINKS.
If any symlinks have been inserted into the path, the open will fail.
(requires Linux 5.6 or later, glibc doesn't have a wrapper)
