]> granicus.if.org Git - imagemagick/commitdiff
(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Sat, 17 May 2014 11:53:50 +0000 (11:53 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Sat, 17 May 2014 11:53:50 +0000 (11:53 +0000)
MagickCore/property.c
MagickCore/utility.c
coders/meta.c
coders/pcd.c

index 9868e822caf2b5b2c1b0e4197b4dace34c2b62bd..284ae1a391c4e174bc12a98de1e73c3c879a88b3 100644 (file)
@@ -3284,9 +3284,8 @@ MagickExport char *InterpretImageProperties(ImageInfo *image_info,
           default:
             p++;
             *q++=(*p);
-            continue;
         }
-        continue; /* never reached! */
+        continue;
       case '&':
         if (LocaleNCompare("&lt;",p,4) == 0)
           *q++='<', p+=3;
index 9faa024ed04833a42c7dba4e5d4144f9396789ea..78aa53c347d69fdae9bdc4e344fee65ea1ae6ea1 100644 (file)
@@ -1916,12 +1916,37 @@ MagickPrivate MagickBooleanType ShredFile(const char *path)
 %    o exception: return any errors here.
 %
 */
+
+static char *SanitizeSystemCommand(const char *command)
+{
+  char
+    *sanitize_command;
+
+  const char
+    *q;
+
+  register char
+    *p;
+
+  static char
+    whitelist[] = 
+      "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-"
+      ".@&;<>|\\\'\":%";
+
+  sanitize_command=AcquireString(command);
+  p=sanitize_command;
+  q=sanitize_command+strlen(sanitize_command);
+  for (p+=strspn(p,whitelist); p != q; p+=strspn(p,whitelist))
+    *p='_';
+  return(sanitize_command);
+}
+
 MagickExport int SystemCommand(const MagickBooleanType asynchronous,
   const MagickBooleanType verbose,const char *command,ExceptionInfo *exception)
 {
   char
     **arguments,
-    *shell_command;
+    *sanitize_command;
 
   int
     number_arguments,
@@ -1964,19 +1989,16 @@ MagickExport int SystemCommand(const MagickBooleanType asynchronous,
       (void) FormatLocaleFile(stderr,"%s\n",command);
       (void) fflush(stderr);
     }
-  shell_command=(char *) command;
+  sanitize_command=SanitizeSystemCommand(command);
   if (asynchronous != MagickFalse)
-    {
-      shell_command=AcquireString(command);
-      (void) ConcatenateMagickString(shell_command,"&",MaxTextExtent);
-    }
+    (void) ConcatenateMagickString(sanitize_command,"&",MaxTextExtent);
 #if defined(MAGICKCORE_POSIX_SUPPORT)
 #if !defined(MAGICKCORE_HAVE_EXECVP)
-  status=system(shell_command);
+  status=system(sanitize_command);
 #else
   if ((asynchronous != MagickFalse) ||
-      (strpbrk(shell_command,"&;<>|") != (char *) NULL))
-    status=system(shell_command);
+      (strpbrk(sanitize_command,"&;<>|") != (char *) NULL))
+    status=system(sanitize_command);
   else
     {
       pid_t
@@ -1987,7 +2009,7 @@ MagickExport int SystemCommand(const MagickBooleanType asynchronous,
       */
       child_pid=(pid_t) fork();
       if (child_pid == (pid_t) -1)
-        status=system(command);
+        status=system(sanitize_command);
       else
         if (child_pid == 0)
           {
@@ -2018,19 +2040,18 @@ MagickExport int SystemCommand(const MagickBooleanType asynchronous,
     }
 #endif
 #elif defined(MAGICKCORE_WINDOWS_SUPPORT)
-  status=NTSystemCommand(shell_command);
+  status=NTSystemCommand(sanitize_command);
 #elif defined(macintosh)
-  status=MACSystemCommand(shell_command);
+  status=MACSystemCommand(sanitize_command);
 #elif defined(vms)
-  status=system(shell_command);
+  status=system(sanitize_command);
 #else
 #  error No suitable system() method.
 #endif
   if (status < 0)
     (void) ThrowMagickException(exception,GetMagickModule(),DelegateError,
       "FailedToExecuteCommand","`%s' (%d)",command,status);
-  if (shell_command != command)
-    shell_command=DestroyString(shell_command);
+  sanitize_command=DestroyString(sanitize_command);
   for (i=0; i < (ssize_t) number_arguments; i++)
     arguments[i]=DestroyString(arguments[i]);
   arguments=(char **) RelinquishMagickMemory(arguments);
index f659ce180456feac1d184ad0feff76c433f68943..7e5d51b3a8c99082e98665466dc3a93e82b10bb4 100644 (file)
@@ -2011,6 +2011,8 @@ static int formatIPTCfromBuffer(Image *ofile, char *s, ssize_t len)
       }
     if (taglen < 0)
       return(-1);
+    if (taglen > 65535)
+      return(-1);
     /* make a buffer to hold the tag datand snag it from the input stream */
     str=(unsigned char *) AcquireQuantumMemory((size_t) (taglen+MaxTextExtent),
       sizeof(*str));
index 0355e981a0c9c6db610b7efa831f319e8b84cda9..a823c641b5b0855b5381fd04d860694e7cb2f6bf 100644 (file)
@@ -552,6 +552,8 @@ static Image *ReadPCDImage(const ImageInfo *image_info,ExceptionInfo *exception)
     ThrowReaderException(CorruptImageError,"ImproperImageHeader");
   rotate=header[0x0e02] & 0x03;
   number_images=(header[10] << 8) | header[11];
+  if (number_images > 65535)
+    ThrowReaderException(CorruptImageError,"ImproperImageHeader");
   header=(unsigned char *) RelinquishMagickMemory(header);
   /*
     Determine resolution by scene specification.