]> wimlib.net Git - wimlib/blobdiff - src/win32_apply.c
mount_image.c: add fallback definitions of RENAME_* constants
[wimlib] / src / win32_apply.c
index 70211cd31b40c34f13516a6c2ca863f6f5dc3f16..e493ecfe298fcd9bb24167586011c5353673159b 100644 (file)
@@ -3,7 +3,7 @@
  */
 
 /*
- * Copyright (C) 2013-2021 Eric Biggers
+ * Copyright 2013-2023 Eric Biggers
  *
  * This file is free software; you can redistribute it and/or modify it under
  * the terms of the GNU Lesser General Public License as published by the Free
@@ -16,7 +16,7 @@
  * details.
  *
  * You should have received a copy of the GNU Lesser General Public License
- * along with this file; if not, see http://www.gnu.org/licenses/.
+ * along with this file; if not, see https://www.gnu.org/licenses/.
  */
 
 #ifdef _WIN32
@@ -1480,7 +1480,7 @@ retry:
        if (unlikely(!NT_SUCCESS(status))) {
                winnt_error(status, L"Can't open \"%ls\" for deletion "
                            "(perms=%x, flags=%x)",
-                           current_path(ctx), perms, flags);
+                           current_path(ctx), (u32)perms, (u32)flags);
                return WIMLIB_ERR_OPEN;
        }
 
@@ -1852,16 +1852,25 @@ create_link(HANDLE h, const struct wim_dentry *dentry,
                info->FileNameLength = ctx->pathbuf.Length;
                memcpy(info->FileName, ctx->pathbuf.Buffer, ctx->pathbuf.Length);
                info->FileName[info->FileNameLength / 2] = L'\0';
+               /*
+                * Note: the null terminator isn't actually necessary, but if
+                * you don't add the extra character, you get
+                * STATUS_INFO_LENGTH_MISMATCH when FileNameLength is 2.
+                */
 
-               /* Note: the null terminator isn't actually necessary,
-                * but if you don't add the extra character, you get
-                * STATUS_INFO_LENGTH_MISMATCH when FileNameLength
-                * happens to be 2  */
-
-               status = NtSetInformationFile(h, &ctx->iosb, info, bufsize,
-                                             FileLinkInformation);
-               if (NT_SUCCESS(status))
-                       return 0;
+               /*
+                * When fuzzing with wlfuzz.exe, creating a hard link sometimes
+                * fails with STATUS_ACCESS_DENIED.  However, it eventually
+                * succeeds when re-attempted...
+                */
+               int i = 0;
+               do {
+                       status = NtSetInformationFile(h, &ctx->iosb, info,
+                                                     bufsize,
+                                                     FileLinkInformation);
+                       if (NT_SUCCESS(status))
+                               return 0;
+               } while (++i < 32);
                winnt_error(status, L"Failed to create link \"%ls\"",
                            current_path(ctx));
                return WIMLIB_ERR_LINK;