fileutils: Make some sample code detect symlinks as intended

The sample code here wasn't a race-free version of the race-susceptible
anti-pattern, because it would have dereferenced a symlink automatically.

Fixes: 293b4923 "Clarify g_file_test() docs about TOCTOU bugs"
Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
Simon McVittie
2023-02-10 13:06:04 +00:00
parent d5bf03cbcb
commit f6e13753aa

View File

@@ -329,7 +329,7 @@ g_mkdir_with_parents (const gchar *pathname,
* } * }
* *
* // DO THIS INSTEAD * // DO THIS INSTEAD
* fd = g_open (filename, O_WRONLY); * fd = g_open (filename, O_WRONLY | O_NOFOLLOW);
* if (fd == -1) * if (fd == -1)
* { * {
* // check error * // check error