glnx-shutil: Cope with ENOENT even after recursing to create parents

If we try to create `link/content` where `link` is a dangling symlink,
recursing to create `link` will succeed (mkdirat fails with EEXIST,
which is explicitly ignored), but then mkdirat for `link/content` will
still fail. Fail gracefully instead of crashing out with an assertion
failure.

Resolves: GNOME/libglnx#1
Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
Simon McVittie
2024-12-05 12:05:59 +00:00
parent f44d944233
commit 2eb4bcc282

View File

@@ -149,12 +149,10 @@ mkdir_p_at_internal (int dfd,
again:
if (mkdirat (dfd, path, mode) == -1)
{
if (errno == ENOENT)
if (errno == ENOENT && !did_recurse)
{
char *lastslash;
g_assert (!did_recurse);
lastslash = strrchr (path, '/');
if (lastslash == NULL)
{