]> granicus.if.org Git - imagemagick/commitdiff
Don't use symbolic links if the shred policy is enabled
authorCristy <urban-warrior@imagemagick.org>
Tue, 29 Aug 2017 10:55:49 +0000 (06:55 -0400)
committerCristy <urban-warrior@imagemagick.org>
Tue, 29 Aug 2017 10:55:49 +0000 (06:55 -0400)
MagickCore/utility.c

index 2eaa5503da6e944ccc89da8f95b32a06b3a91377..64b74ce667b63f2b396a49e1b0fccfc2d585ad91 100644 (file)
@@ -173,26 +173,38 @@ MagickExport MagickBooleanType AcquireUniqueSymbolicLink(const char *source,
   assert(source != (const char *) NULL);
   assert(destination != (char *) NULL);
 #if defined(MAGICKCORE_HAVE_SYMLINK)
-  (void) AcquireUniqueFilename(destination);
-  (void) RelinquishUniqueFileResource(destination);
-  if (*source == *DirectorySeparator)
-    {
-      if (symlink(source,destination) == 0)
-        return(MagickTrue);
-    }
-  else
-    {
-      char
-        path[MagickPathExtent];
+  {
+    char
+      *passes;
 
-      *path='\0';
-      if (getcwd(path,MagickPathExtent) == (char *) NULL)
-        return(MagickFalse);
-      (void) ConcatenateMagickString(path,DirectorySeparator,MagickPathExtent);
-      (void) ConcatenateMagickString(path,source,MagickPathExtent);
-      if (symlink(path,destination) == 0)
-        return(MagickTrue);
-    }
+    (void) AcquireUniqueFilename(destination);
+    (void) RelinquishUniqueFileResource(destination);
+    passes=GetPolicyValue("system:shred");
+    if (passes != (char *) NULL)
+      passes=DestroyString(passes);
+    else
+      {
+        if (*source == *DirectorySeparator)
+          {
+            if (symlink(source,destination) == 0)
+              return(MagickTrue);
+          }
+        else
+          {
+            char
+              path[MagickPathExtent];
+
+            *path='\0';
+            if (getcwd(path,MagickPathExtent) == (char *) NULL)
+              return(MagickFalse);
+            (void) ConcatenateMagickString(path,DirectorySeparator,
+              MagickPathExtent);
+            (void) ConcatenateMagickString(path,source,MagickPathExtent);
+            if (symlink(path,destination) == 0)
+              return(MagickTrue);
+          }
+      }
+  }
 #endif
   destination_file=AcquireUniqueFileResource(destination);
   if (destination_file == -1)