From: Cristy Date: Tue, 29 Aug 2017 10:55:49 +0000 (-0400) Subject: Don't use symbolic links if the shred policy is enabled X-Git-Tag: 7.0.7-0~45 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f054246f9f3654f7ff4ca830c2732f41051ee1e1;p=imagemagick Don't use symbolic links if the shred policy is enabled --- diff --git a/MagickCore/utility.c b/MagickCore/utility.c index 2eaa5503d..64b74ce66 100644 --- a/MagickCore/utility.c +++ b/MagickCore/utility.c @@ -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)