Commit c081559f9 for imagemagick.org

commit c081559f9bf32c2613c2b46e2f469593a12dab26
Author: Cristy <urban-warrior@imagemagick.org>
Date:   Sat Jul 11 09:54:37 2026 -0400

    include file mode when validating file identity

diff --git a/MagickCore/nt-base.c b/MagickCore/nt-base.c
index 6df3f9313..e02217721 100644
--- a/MagickCore/nt-base.c
+++ b/MagickCore/nt-base.c
@@ -2671,19 +2671,32 @@ MagickExport int NTStatWide(const char *path,struct stat *attributes)
           BY_HANDLE_FILE_INFORMATION
             file_info;

+          /*
+            POSIX emulation of Windows file attributes.
+          */
           if (GetFileInformationByHandle(handle,&file_info) != 0)
             {
-              /*
-                Map Windows file identity into st_dev/st_ino.
-              */
               attributes->st_dev=(dev_t) file_info.dwVolumeSerialNumber;
               attributes->st_ino=MapFileIndexToIno((((uint64_t)
                 file_info.nFileIndexHigh) << 32) | (uint64_t)
                 file_info.nFileIndexLow);
-          }
-        CloseHandle(handle);
-      }
-    }
+              attributes->st_mode=0;
+              if ((file_info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0)
+                attributes->st_mode|=S_IFDIR;
+              else
+                if ((file_info.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0)
+                  attributes->st_mode|=S_IFLNK;
+                else
+                  attributes->st_mode|=S_IFREG;
+                if (file_info.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
+                  attributes->st_mode|=S_IRUSR | S_IRGRP | S_IROTH;
+                else
+                  attributes->st_mode|=S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP |
+                    S_IROTH | S_IWOTH;
+            }
+          CloseHandle(handle);
+        }
+  }
   path_wide=(WCHAR *) RelinquishMagickMemory(path_wide);
   return(status);
 }
diff --git a/MagickCore/resource.c b/MagickCore/resource.c
index 05c77d8ec..b0502173e 100644
--- a/MagickCore/resource.c
+++ b/MagickCore/resource.c
@@ -740,7 +740,8 @@ MagickExport MagickBooleanType IsFileResourceIdentityValid(const char *path)
       status=GetPathAttributes(path,&attributes);
       if (status != MagickFalse)
         if ((attributes.st_dev != temporary_attributes->st_dev) ||
-            (attributes.st_ino != temporary_attributes->st_ino))
+            (attributes.st_ino != temporary_attributes->st_ino) ||
+            (attributes.st_mode != temporary_attributes->st_mode))
           status=MagickFalse;
     }
   UnlockSemaphoreInfo(resource_semaphore[FileResource]);