]> granicus.if.org Git - imagemagick/commitdiff
...
authorCristy <urban-warrior@imagemagick.org>
Sat, 24 Dec 2016 19:11:46 +0000 (14:11 -0500)
committerCristy <urban-warrior@imagemagick.org>
Sat, 24 Dec 2016 19:11:46 +0000 (14:11 -0500)
MagickCore/resource.c

index d2eaa33c908f348d8a066d8ae5f87a5e30eec458..700c57c107622e0fd20bc629ecb4827bcb5b6e1b 100644 (file)
 #include "MagickCore/utility.h"
 #include "MagickCore/utility-private.h"
 \f
+/*
+  Define declarations.
+*/
+#define MagickPathTemplate "XXXXXXXXXXXX"
+\f
 /*
   Typedef declarations.
 */
@@ -403,8 +408,8 @@ MagickExport MagickBooleanType GetPathTemplate(char *path)
   struct stat
     attributes;
 
-  (void) FormatLocaleString(path,MagickPathExtent,"magick-%.20gXXXXXXXXXXXX",
-    (double) getpid());
+  (void) FormatLocaleString(path,MagickPathExtent,"magick-%.20g"
+    MagickPathTemplate,(double) getpid());
   exception=AcquireExceptionInfo();
   directory=(char *) GetImageRegistry(StringRegistryType,"temporary-path",
     exception);
@@ -450,11 +455,11 @@ MagickExport MagickBooleanType GetPathTemplate(char *path)
     }
   if (directory[strlen(directory)-1] == *DirectorySeparator)
     (void) FormatLocaleString(path,MagickPathExtent,
-      "%smagick-%.20gXXXXXXXXXXXX",directory,(double) getpid());
+      "%smagick-%.20g" MagickPathTemplate,directory,(double) getpid());
   else
     (void) FormatLocaleString(path,MagickPathExtent,
-      "%s%smagick-%.20gXXXXXXXXXXXX",directory,DirectorySeparator,(double)
-      getpid());
+      "%s%smagick-%.20g" MagickPathTemplate,directory,DirectorySeparator,
+      (double) getpid());
   directory=DestroyString(directory);
 #if defined(MAGICKCORE_WINDOWS_SUPPORT)
   {
@@ -519,7 +524,7 @@ MagickExport int AcquireUniqueFileResource(char *path)
     */
     (void) GetPathTemplate(path);
     key=GetRandomKey(random_info,6);
-    p=path+strlen(path)-12;
+    p=path+strlen(path)-strlen(MagickPathTemplate);
     datum=GetStringInfoDatum(key);
     for (i=0; i < (ssize_t) GetStringInfoLength(key); i++)
     {
@@ -540,8 +545,8 @@ MagickExport int AcquireUniqueFileResource(char *path)
         break;
       }
 #endif
-    key=GetRandomKey(random_info,12);
-    p=path+strlen(path)-12;
+    key=GetRandomKey(random_info,strlen(MagickPathTemplate));
+    p=path+strlen(path)-strlen(MagickPathTemplate);
     datum=GetStringInfoDatum(key);
     for (i=0; i < (ssize_t) GetStringInfoLength(key); i++)
     {