GraphicsMagick: 3 new changesets

GraphicsMagick Commits <[email protected]> Thu, 19 Dec 2024 13:36:21 -0600
Newsgroups gmane.comp.video.graphicsmagick.cvs
Message-ID <mailman.42668.1734636992.7812.graphicsmagick-commit@lists.sourceforge.net>
changeset 883ebf8cae6d in /hg/GraphicsMagick
details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=883ebf8cae6d
summary: ReadWPGImage(): Assure that palette buffer is allocated and the current size.

changeset 831362b618f7 in /hg/GraphicsMagick
details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=831362b618f7
summary: PerlMagick/t/input2_TC1.wpg: Fix accidental file overwrite

changeset 5130d75a290e in /hg/GraphicsMagick
details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=5130d75a290e
summary: coders/wpg.c: Reformat white-space to be more similar to conventions used in the rest of the software.

diffstat:

 ChangeLog                              |     8 +
 VisualMagick/installer/inc/version.isx |     4 +-
 coders/wpg.c                           |  1725 ++++++++++++++++---------------
 magick/version.h                       |     4 +-
 www/ChangeLog.html                     |    10 +
 5 files changed, 921 insertions(+), 830 deletions(-)

diffs (truncated from 2545 to 500 lines):

diff -r cf7cd5ebabb0 -r 5130d75a290e ChangeLog
--- a/ChangeLog	Mon Dec 16 10:50:23 2024 -0600
+++ b/ChangeLog	Thu Dec 19 13:35:31 2024 -0600
@@ -1,3 +1,11 @@
+2024-12-19  Bob Friesenhahn  <[email protected]>
+
+	* coders/wpg.c (ReadWPGImage): Assure that palette buffer is
+	allocated and the current size. Addresses SourceForge bug #750
+	"heap-buffer-overflow in ReadBlob".
+	Reformat white-space to be more similar to conventions used in
+	the rest of the software.
+
 2024-12-16  Bob Friesenhahn  <[email protected]>
 
 	* config/delegates.mgk.in: Use XML predefined entities
diff -r cf7cd5ebabb0 -r 5130d75a290e VisualMagick/installer/inc/version.isx
--- a/VisualMagick/installer/inc/version.isx	Mon Dec 16 10:50:23 2024 -0600
+++ b/VisualMagick/installer/inc/version.isx	Thu Dec 19 13:35:31 2024 -0600
@@ -10,5 +10,5 @@
 
 #define public MagickPackageName "GraphicsMagick"
 #define public MagickPackageVersion "1.4"
-#define public MagickPackageVersionAddendum ".020241216"
-#define public MagickPackageReleaseDate "snapshot-20241216"
+#define public MagickPackageVersionAddendum ".020241219"
+#define public MagickPackageReleaseDate "snapshot-20241219"
diff -r cf7cd5ebabb0 -r 5130d75a290e coders/wpg.c
--- a/coders/wpg.c	Mon Dec 16 10:50:23 2024 -0600
+++ b/coders/wpg.c	Thu Dec 19 13:35:31 2024 -0600
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2023 GraphicsMagick Group
+% Copyright (C) 2003-2024 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 %
 % This program is covered by multiple licenses, which are described in
@@ -51,157 +51,159 @@
 
 
 typedef struct
-   {
-   unsigned char Red;
-   unsigned char Blue;
-   unsigned char Green;
-   } RGB_Record;
+{
+  unsigned char Red;
+  unsigned char Blue;
+  unsigned char Green;
+} RGB_Record;
 
 /* Default palette for WPG level 1 */
-static const RGB_Record WPG1_Palette[256]={
-{  0,  0,  0},          {  0,  0,168},
-{  0,168,  0},          {  0,168,168},
-{168,  0,  0},          {168,  0,168},
-{168, 84,  0},          {168,168,168},
-{ 84, 84, 84},          { 84, 84,252},
-{ 84,252, 84},          { 84,252,252},
-{252, 84, 84},          {252, 84,252},
-{252,252, 84},          {252,252,252},  /*16*/
-{  0,  0,  0},          { 20, 20, 20},
-{ 32, 32, 32},          { 44, 44, 44},
-{ 56, 56, 56},          { 68, 68, 68},
-{ 80, 80, 80},          { 96, 96, 96},
-{112,112,112},          {128,128,128},
-{144,144,144},          {160,160,160},
-{180,180,180},          {200,200,200},
-{224,224,224},          {252,252,252},  /*32*/
-{  0,  0,252},          { 64,  0,252},
-{124,  0,252},          {188,  0,252},
-{252,  0,252},          {252,  0,188},
-{252,  0,124},          {252,  0, 64},
-{252,  0,  0},          {252, 64,  0},
-{252,124,  0},          {252,188,  0},
-{252,252,  0},          {188,252,  0},
-{124,252,  0},          { 64,252,  0},  /*48*/
-{  0,252,  0},          {  0,252, 64},
-{  0,252,124},          {  0,252,188},
-{  0,252,252},          {  0,188,252},
-{  0,124,252},          {  0, 64,252},
-{124,124,252},          {156,124,252},
-{188,124,252},          {220,124,252},
-{252,124,252},          {252,124,220},
-{252,124,188},          {252,124,156},  /*64*/
-{252,124,124},          {252,156,124},
-{252,188,124},          {252,220,124},
-{252,252,124},          {220,252,124},
-{188,252,124},          {156,252,124},
-{124,252,124},          {124,252,156},
-{124,252,188},          {124,252,220},
-{124,252,252},          {124,220,252},
-{124,188,252},          {124,156,252},  /*80*/
-{180,180,252},          {196,180,252},
-{216,180,252},          {232,180,252},
-{252,180,252},          {252,180,232},
-{252,180,216},          {252,180,196},
-{252,180,180},          {252,196,180},
-{252,216,180},          {252,232,180},
-{252,252,180},          {232,252,180},
-{216,252,180},          {196,252,180},  /*96*/
-{180,220,180},          {180,252,196},
-{180,252,216},          {180,252,232},
-{180,252,252},          {180,232,252},
-{180,216,252},          {180,196,252},
-{0,0,112},              {28,0,112},
-{56,0,112},             {84,0,112},
-{112,0,112},            {112,0,84},
-{112,0,56},             {112,0,28},     /*112*/
-{112,0,0},              {112,28,0},
-{112,56,0},             {112,84,0},
-{112,112,0},            {84,112,0},
-{56,112,0},             {28,112,0},
-{0,112,0},              {0,112,28},
-{0,112,56},             {0,112,84},
-{0,112,112},            {0,84,112},
-{0,56,112},             {0,28,112},     /*128*/
-{56,56,112},            {68,56,112},
-{84,56,112},            {96,56,112},
-{112,56,112},           {112,56,96},
-{112,56,84},            {112,56,68},
-{112,56,56},            {112,68,56},
-{112,84,56},            {112,96,56},
-{112,112,56},           {96,112,56},
-{84,112,56},            {68,112,56},    /*144*/
-{56,112,56},            {56,112,69},
-{56,112,84},            {56,112,96},
-{56,112,112},           {56,96,112},
-{56,84,112},            {56,68,112},
-{80,80,112},            {88,80,112},
-{96,80,112},            {104,80,112},
-{112,80,112},           {112,80,104},
-{112,80,96},            {112,80,88},    /*160*/
-{112,80,80},            {112,88,80},
-{112,96,80},            {112,104,80},
-{112,112,80},           {104,112,80},
-{96,112,80},            {88,112,80},
-{80,112,80},            {80,112,88},
-{80,112,96},            {80,112,104},
-{80,112,112},           {80,114,112},
-{80,96,112},            {80,88,112},    /*176*/
-{0,0,64},               {16,0,64},
-{32,0,64},              {48,0,64},
-{64,0,64},              {64,0,48},
-{64,0,32},              {64,0,16},
-{64,0,0},               {64,16,0},
-{64,32,0},              {64,48,0},
-{64,64,0},              {48,64,0},
-{32,64,0},              {16,64,0},      /*192*/
-{0,64,0},               {0,64,16},
-{0,64,32},              {0,64,48},
-{0,64,64},              {0,48,64},
-{0,32,64},              {0,16,64},
-{32,32,64},             {40,32,64},
-{48,32,64},             {56,32,64},
-{64,32,64},             {64,32,56},
-{64,32,48},             {64,32,40},     /*208*/
-{64,32,32},             {64,40,32},
-{64,48,32},             {64,56,32},
-{64,64,32},             {56,64,32},
-{48,64,32},             {40,64,32},
-{32,64,32},             {32,64,40},
-{32,64,48},             {32,64,56},
-{32,64,64},             {32,56,64},
-{32,48,64},             {32,40,64},     /*224*/
-{44,44,64},             {48,44,64},
-{52,44,64},             {60,44,64},
-{64,44,64},             {64,44,60},
-{64,44,52},             {64,44,48},
-{64,44,44},             {64,48,44},
-{64,52,44},             {64,60,44},
-{64,64,44},             {60,64,44},
-{52,64,44},             {48,64,44},     /*240*/
-{44,64,44},             {44,64,48},
-{44,64,52},             {44,64,60},
-{44,64,64},             {44,60,64},
-{44,55,64},             {44,48,64},
-{0,0,0},                {0,0,0},
-{0,0,0},                {0,0,0},
-{0,0,0},                {0,0,0},
-{0,0,0},                {0,0,0}         /*256*/
-};
+static const RGB_Record WPG1_Palette[256] =
+  {
+    {  0,  0,  0},          {  0,  0,168},
+    {  0,168,  0},          {  0,168,168},
+    {168,  0,  0},          {168,  0,168},
+    {168, 84,  0},          {168,168,168},
+    { 84, 84, 84},          { 84, 84,252},
+    { 84,252, 84},          { 84,252,252},
+    {252, 84, 84},          {252, 84,252},
+    {252,252, 84},          {252,252,252},  /*16*/
+    {  0,  0,  0},          { 20, 20, 20},
+    { 32, 32, 32},          { 44, 44, 44},
+    { 56, 56, 56},          { 68, 68, 68},
+    { 80, 80, 80},          { 96, 96, 96},
+    {112,112,112},          {128,128,128},
+    {144,144,144},          {160,160,160},
+    {180,180,180},          {200,200,200},
+    {224,224,224},          {252,252,252},  /*32*/
+    {  0,  0,252},          { 64,  0,252},
+    {124,  0,252},          {188,  0,252},
+    {252,  0,252},          {252,  0,188},
+    {252,  0,124},          {252,  0, 64},
+    {252,  0,  0},          {252, 64,  0},
+    {252,124,  0},          {252,188,  0},
+    {252,252,  0},          {188,252,  0},
+    {124,252,  0},          { 64,252,  0},  /*48*/
+    {  0,252,  0},          {  0,252, 64},
+    {  0,252,124},          {  0,252,188},
+    {  0,252,252},          {  0,188,252},
+    {  0,124,252},          {  0, 64,252},
+    {124,124,252},          {156,124,252},
+    {188,124,252},          {220,124,252},
+    {252,124,252},          {252,124,220},
+    {252,124,188},          {252,124,156},  /*64*/
+    {252,124,124},          {252,156,124},
+    {252,188,124},          {252,220,124},
+    {252,252,124},          {220,252,124},
+    {188,252,124},          {156,252,124},
+    {124,252,124},          {124,252,156},
+    {124,252,188},          {124,252,220},
+    {124,252,252},          {124,220,252},
+    {124,188,252},          {124,156,252},  /*80*/
+    {180,180,252},          {196,180,252},
+    {216,180,252},          {232,180,252},
+    {252,180,252},          {252,180,232},
+    {252,180,216},          {252,180,196},
+    {252,180,180},          {252,196,180},
+    {252,216,180},          {252,232,180},
+    {252,252,180},          {232,252,180},
+    {216,252,180},          {196,252,180},  /*96*/
+    {180,220,180},          {180,252,196},
+    {180,252,216},          {180,252,232},
+    {180,252,252},          {180,232,252},
+    {180,216,252},          {180,196,252},
+    {0,0,112},              {28,0,112},
+    {56,0,112},             {84,0,112},
+    {112,0,112},            {112,0,84},
+    {112,0,56},             {112,0,28},     /*112*/
+    {112,0,0},              {112,28,0},
+    {112,56,0},             {112,84,0},
+    {112,112,0},            {84,112,0},
+    {56,112,0},             {28,112,0},
+    {0,112,0},              {0,112,28},
+    {0,112,56},             {0,112,84},
+    {0,112,112},            {0,84,112},
+    {0,56,112},             {0,28,112},     /*128*/
+    {56,56,112},            {68,56,112},
+    {84,56,112},            {96,56,112},
+    {112,56,112},           {112,56,96},
+    {112,56,84},            {112,56,68},
+    {112,56,56},            {112,68,56},
+    {112,84,56},            {112,96,56},
+    {112,112,56},           {96,112,56},
+    {84,112,56},            {68,112,56},    /*144*/
+    {56,112,56},            {56,112,69},
+    {56,112,84},            {56,112,96},
+    {56,112,112},           {56,96,112},
+    {56,84,112},            {56,68,112},
+    {80,80,112},            {88,80,112},
+    {96,80,112},            {104,80,112},
+    {112,80,112},           {112,80,104},
+    {112,80,96},            {112,80,88},    /*160*/
+    {112,80,80},            {112,88,80},
+    {112,96,80},            {112,104,80},
+    {112,112,80},           {104,112,80},
+    {96,112,80},            {88,112,80},
+    {80,112,80},            {80,112,88},
+    {80,112,96},            {80,112,104},
+    {80,112,112},           {80,114,112},
+    {80,96,112},            {80,88,112},    /*176*/
+    {0,0,64},               {16,0,64},
+    {32,0,64},              {48,0,64},
+    {64,0,64},              {64,0,48},
+    {64,0,32},              {64,0,16},
+    {64,0,0},               {64,16,0},
+    {64,32,0},              {64,48,0},
+    {64,64,0},              {48,64,0},
+    {32,64,0},              {16,64,0},      /*192*/
+    {0,64,0},               {0,64,16},
+    {0,64,32},              {0,64,48},
+    {0,64,64},              {0,48,64},
+    {0,32,64},              {0,16,64},
+    {32,32,64},             {40,32,64},
+    {48,32,64},             {56,32,64},
+    {64,32,64},             {64,32,56},
+    {64,32,48},             {64,32,40},     /*208*/
+    {64,32,32},             {64,40,32},
+    {64,48,32},             {64,56,32},
+    {64,64,32},             {56,64,32},
+    {48,64,32},             {40,64,32},
+    {32,64,32},             {32,64,40},
+    {32,64,48},             {32,64,56},
+    {32,64,64},             {32,56,64},
+    {32,48,64},             {32,40,64},     /*224*/
+    {44,44,64},             {48,44,64},
+    {52,44,64},             {60,44,64},
+    {64,44,64},             {64,44,60},
+    {64,44,52},             {64,44,48},
+    {64,44,44},             {64,48,44},
+    {64,52,44},             {64,60,44},
+    {64,64,44},             {60,64,44},
+    {52,64,44},             {48,64,44},     /*240*/
+    {44,64,44},             {44,64,48},
+    {44,64,52},             {44,64,60},
+    {44,64,64},             {44,60,64},
+    {44,55,64},             {44,48,64},
+    {0,0,0},                {0,0,0},
+    {0,0,0},                {0,0,0},
+    {0,0,0},                {0,0,0},
+    {0,0,0},                {0,0,0}         /*256*/
+  };
 
 
 static int ApproveFormatForWPG(const char *Format, ExceptionInfo *exception)
 {
-  const MagickInfo *magick_info;
+  const MagickInfo *
+    magick_info;
 
-  if(!strcmp(Format,"PFB")) return 0;
+  if (!strcmp(Format,"PFB")) return 0;
 
-  /*if(!strcmp(Format,"8BIMTEXT")) return 0; This test is no longer needed, META module includes this case. */
+  /*if (!strcmp(Format,"8BIMTEXT")) return 0; This test is no longer needed, META module includes this case. */
   magick_info = GetMagickInfo(Format,exception);
-  if(magick_info != (const MagickInfo *)NULL)
-  {
-    if(strcmp(magick_info->module, "META") == 0) return 0;
-  }
+  if (magick_info != (const MagickInfo *)NULL)
+    {
+      if (strcmp(magick_info->module, "META") == 0) return 0;
+    }
 
   return 1;
 }
@@ -248,7 +250,8 @@
 
 static int Rd_WP_DWORD(Image *image, magick_uint32_t *d)
 {
-  unsigned char b;
+  unsigned char
+    b;
 
   b = ReadBlobByte(image);
   *d = b;
@@ -273,30 +276,37 @@
 {
   unsigned long
     x;
+
   register PixelPacket
     *q;
-  MagickPassFail RetVal = MagickFail;
-  IndexPacket index;
-  IndexPacket *indexes;
+
+  MagickPassFail
+    RetVal = MagickFail;
+
+  IndexPacket
+    index;
+
+  IndexPacket *
+    indexes;
 
   if (image->logging)
     (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                           "Insert row %ld of %lu...", y, image->rows);
 
   q = SetImagePixels(image,0,y,image->columns,1);
-  if(q == (PixelPacket *) NULL)
+  if (q == (PixelPacket *) NULL)
     return MagickFail;
 
   switch (bpp)
     {
     case 1:  /* Convert bitmap scanline. WP seems to ignore palette even if it is present. */
-        RetVal = ImportImagePixelArea(image,GrayQuantum,bpp,p,NULL,0);
-        break;
+      RetVal = ImportImagePixelArea(image,GrayQuantum,bpp,p,NULL,0);
+      break;
 
     case 4:  /* Convert PseudoColor scanline. */
     case 8:  /* Convert PseudoColor scanline. */
-        RetVal = ImportImagePixelArea(image,IndexQuantum,bpp,p,NULL,0);
-        break;
+      RetVal = ImportImagePixelArea(image,IndexQuantum,bpp,p,NULL,0);
+      break;
 
     case 2:  /* Convert PseudoColor scanline. */
       {
@@ -307,10 +317,10 @@
             if (image->logging)
               (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                                     "Image has no colormap, skipping...");
-          return MagickFail;
+            return MagickFail;
           }
         x = 0;
-        while(x+3 < image->columns)
+        while (x+3 < image->columns)
           {
             index = (IndexPacket)((*p >> 6) & 0x3);
             VerifyColormapIndex(image,index);
@@ -330,19 +340,19 @@
             *q++ = image->colormap[index];
             p++;
           }
-        if(x < image->columns)
+        if (x < image->columns)
           {
             index = (IndexPacket) ((*p >> 6) & 0x3);
             VerifyColormapIndex(image,index);
             indexes[x++] = index;
             *q++=image->colormap[index];
-            if(x < image->columns)
+            if (x < image->columns)
               {
                 index = (IndexPacket) ((*p >> 4) & 0x3);
                 VerifyColormapIndex(image,index);
                 indexes[x++] = index;
                 *q++=image->colormap[index];
-                if(x < image->columns)
+                if (x < image->columns)
                   {
                     index = (IndexPacket)((*p >> 2) & 0x3);
                     VerifyColormapIndex(image,index);
@@ -369,62 +379,70 @@
     }
 
 
-  if(RetVal==MagickFail)
-  {
-    (void) LogMagickEvent(CoderEvent,GetMagickModule(),"ImportImagePixelArea failed for row: %lu, bpp: %d", y, bpp);
-    return MagickFail;
-  }
+  if (RetVal==MagickFail)
+    {
+      (void) LogMagickEvent(CoderEvent,GetMagickModule(),"ImportImagePixelArea failed for row: %lu, bpp: %d", y, bpp);
+      return MagickFail;
+    }
 
-  if(!SyncImagePixels(image))
-  {
-    (void) LogMagickEvent(CoderEvent,GetMagickModule(),"SyncImagePixels failed for row: %ld, bpp: %d", y, bpp);
-    return MagickFail;
-  }
+  if (!SyncImagePixels(image))
+    {
+      (void) LogMagickEvent(CoderEvent,GetMagickModule(),"SyncImagePixels failed for row: %ld, bpp: %d", y, bpp);
+      return MagickFail;
+    }
 
-return RetVal;
+  return RetVal;
 }
 
 
 /* Helper for WPG1 raster reader. */
-#define InsertByte(b) \
-{ \
-  BImgBuff[x]=b; \
-  x++; \
-  if((long) x>=ldblk) \
-  { \
-    if(InsertRow(BImgBuff,y,image,bpp)==MagickFail) { RetVal=-6; goto unpack_wpg_raser_error; } \
-    x=0; \
-    y++; \
-    if(y>=image->rows) break; \
-    } \
+#define InsertByte(b)                                                   \
+  {                                                                     \
+    BImgBuff[x]=b;                                                      \
+    x++;                                                                \
+    if ((long) x>=ldblk)                                                \
+      {                                                                 \
+        if (InsertRow(BImgBuff,y,image,bpp)==MagickFail)                \
+          {                                                             \
+            RetVal=-6;                                                  \
+            goto unpack_wpg_raser_error;                                \
+          }                                                             \
+        x=0;                                                            \
+        y++;                                                            \
+        if (y>=image->rows) break;                                      \
+      }                                                                 \
 }
 
 
 /** Call this function to ensure that all data matrix is filled with something. This function
  * is used only to error recovery. */
-static MagickPassFail ZeroFillMissingData(unsigned char *BImgBuff,unsigned long x, unsigned long y, Image *image,
-                                          int bpp, long ldblk)
+static MagickPassFail ZeroFillMissingData(unsigned char *BImgBuff,
+                                          unsigned long x,
+                                          unsigned long y,
+                                          Image *image,
+                                          int bpp,