GraphicsMagick: 2 new changesets
GraphicsMagick Commits <[email protected]>
| Newsgroups | gmane.comp.video.graphicsmagick.cvs |
|---|---|
| Message-ID | <mailman.12095.1636054331.2008.graphicsmagick-commit@lists.sourceforge.net> |
changeset e6de7a092d0d in /hg/GraphicsMagick details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=e6de7a092d0d summary: Added StringToDisposeType() and DisposeTypeToString() changeset 02742ac3634d in /hg/GraphicsMagick details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=02742ac3634d summary: ReadGIFImage(): Handle GIF files where the 'opaque' index matches the number of colors by producing an extra colormap entry of transparent black. diffstat: ChangeLog | 11 +++++++++++ coders/gif.c | 39 +++++++++++++++++++++++++++++++++------ magick/enum_strings.c | 40 ++++++++++++++++++++++++++++++++++++++++ magick/enum_strings.h | 2 ++ www/Changelog.html | 14 ++++++++++++-- 5 files changed, 98 insertions(+), 8 deletions(-) diffs (218 lines): diff -r 9dacc3ab04f2 -r 02742ac3634d ChangeLog --- a/ChangeLog Thu Nov 04 08:47:57 2021 -0500 +++ b/ChangeLog Thu Nov 04 14:31:44 2021 -0500 @@ -1,5 +1,16 @@ 2021-11-04 Bob Friesenhahn <[email protected]> + * coders/gif.c (ReadGIFImage): Handle GIF files where the 'opaque' + index matches the number of colors by producing an extra colormap + entry of transparent black. Fixes SourceForge issue 649 "Bug with + gm identify" where the test case produces the error "Invalid + colormap index (index 128 >= 128 colors, /tmp/broken.gif)". + + * magick/enum_strings.c (StringToDisposeType): New utility + function to convert a string to a DisposeType. + (DisposeTypeToString) New utility function to convert a + DisposeType to a string. + * coders/msl.c (MSLEndElement): Ignore imbalanced group closure. Fixes oss-fuzz 40680 "graphicsmagick:coder_MSL_fuzzer: Heap-buffer-overflow in MSLEndElement". diff -r 9dacc3ab04f2 -r 02742ac3634d coders/gif.c --- a/coders/gif.c Thu Nov 04 08:47:57 2021 -0500 +++ b/coders/gif.c Thu Nov 04 14:31:44 2021 -0500 @@ -40,6 +40,7 @@ #include "magick/blob.h" #include "magick/color.h" #include "magick/colormap.h" +#include "magick/enum_strings.h" #include "magick/log.h" #include "magick/magick.h" #include "magick/monitor.h" @@ -870,7 +871,8 @@ magick[12]; unsigned int - global_colors; + global_colors=0, + local_colors=0; unsigned long delay, @@ -892,14 +894,20 @@ /* Determine if this is a GIF file. */ + (void) memset(magick,0,sizeof(magick)); count=ReadBlob(image,6,(char *) magick); if ((count != 6) || ((LocaleNCompare((char *) magick,"GIF87",5) != 0) && (LocaleNCompare((char *) magick,"GIF89",5) != 0))) ThrowReaderException(CorruptImageError,ImproperImageHeader,image); - global_colors=0; + if (image->logging) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "Magick: %.6s",magick); global_colormap=(unsigned char *) NULL; page.width=ReadBlobLSBShort(image); page.height=ReadBlobLSBShort(image); + if (image->logging) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "Canvas Page: %lux%lu", page.width, page.height); flag=ReadBlobByte(image); background=ReadBlobByte(image); c=ReadBlobByte(image); /* reserved */ @@ -908,6 +916,9 @@ if (global_colormap == (unsigned char *) NULL) ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image); (void) memset(global_colormap,0,(size_t) 3*Max(global_colors,256U)); + if (image->logging) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "Global Colors: %u", global_colors); if (BitSet(flag,0x80)) { if (ReadBlob(image,(size_t) 3*global_colors,(char *) global_colormap) != (size_t) 3U*global_colors) @@ -1070,8 +1081,11 @@ image->depth=8; flag=ReadBlobByte(image); image->interlace=BitSet(flag,0x40) ? LineInterlace : NoInterlace; - image->colors=!BitSet(flag,0x80) ? global_colors : 0x01U << ((flag & 0x07)+1); - if (opacity >= (long) image->colors) + local_colors=!BitSet(flag,0x80) ? global_colors : 0x01U << ((flag & 0x07)+1); + image->colors=local_colors; + if (opacity == (long) image->colors) /* Add an extra color for transparent black */ + image->colors++; + else if (opacity >= (long) image->colors) opacity=(-1); image->page.width=page.width; image->page.height=page.height; @@ -1088,6 +1102,19 @@ MagickFreeMemory(global_colormap); ThrowReaderException(CorruptImageError,NegativeOrZeroImageSize,image); } + if (image->logging) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + "Image[%lu]: %lux%lu, Page: %lux%lu+%ld+%ld, Colors=%u, " + " Interlace: %s, Matte: %s, Delay: %lu, Dispose: %s, Iterations: %lu", + image->scene, + image->columns, image->rows, + image->page.width, image->page.height, image->page.x, image->page.y, + image->colors, + InterlaceTypeToString(image->interlace), + image->matte ? "True" : "False", + image->delay, + DisposeTypeToString(image->dispose), + image->iterations); /* Inititialize colormap. */ @@ -1121,14 +1148,14 @@ /* Read local colormap. */ - colormap=MagickAllocateArray(unsigned char *,3,image->colors); + colormap=MagickAllocateClearedArray(unsigned char *,3,image->colors); if (colormap == (unsigned char *) NULL) { MagickFreeMemory(global_colormap); ThrowReaderException(ResourceLimitError,MemoryAllocationFailed, image); } - if (ReadBlob(image, (size_t) 3*image->colors,(char *) colormap) != (size_t) 3*image->colors) + if (ReadBlob(image, (size_t) 3*local_colors,(char *) colormap) != (size_t) 3*local_colors) { MagickFreeMemory(global_colormap); MagickFreeMemory(colormap); diff -r 9dacc3ab04f2 -r 02742ac3634d magick/enum_strings.c --- a/magick/enum_strings.c Thu Nov 04 08:47:57 2021 -0500 +++ b/magick/enum_strings.c Thu Nov 04 14:31:44 2021 -0500 @@ -658,6 +658,46 @@ } /* + DisposeType + */ +MagickExport DisposeType StringToDisposeType(const char *option) +{ + DisposeType dispose_type = UndefinedDispose; + + if (LocaleCompare("None",option) == 0) + dispose_type = NoneDispose; + else if (LocaleCompare("Background",option) == 0) + dispose_type = BackgroundDispose; + else if (LocaleCompare("Previous",option) == 0) + dispose_type = PreviousDispose; + + return dispose_type; +} +MagickExport const char *DisposeTypeToString(const DisposeType dispose_type) +{ + const char + *dispose_string="?"; + + switch (dispose_type) + { + case UndefinedDispose: + dispose_string = "Undefined"; + break; + case NoneDispose: + dispose_string = "None"; + break; + case BackgroundDispose: + dispose_string = "Background"; + break; + case PreviousDispose: + dispose_string = "Previous"; + break; + } + + return dispose_string; +} + +/* ConfirmAccessMode */ MagickExport const char *ConfirmAccessModeToString(const ConfirmAccessMode access_mode) diff -r 9dacc3ab04f2 -r 02742ac3634d magick/enum_strings.h --- a/magick/enum_strings.h Thu Nov 04 08:47:57 2021 -0500 +++ b/magick/enum_strings.h Thu Nov 04 14:31:44 2021 -0500 @@ -33,6 +33,7 @@ extern MagickExport ColorspaceType StringToColorspaceType(const char *colorspace_string) MAGICK_FUNC_PURE; extern MagickExport CompositeOperator StringToCompositeOperator(const char *option) MAGICK_FUNC_PURE; extern MagickExport CompressionType StringToCompressionType(const char *option) MAGICK_FUNC_PURE; + extern MagickExport DisposeType StringToDisposeType(const char *option) MAGICK_FUNC_PURE; extern MagickExport EndianType StringToEndianType(const char *option) MAGICK_FUNC_PURE; extern MagickExport FilterTypes StringToFilterTypes(const char *option) MAGICK_FUNC_PURE; extern MagickExport GravityType StringToGravityType(const char *option) MAGICK_FUNC_PURE; @@ -54,6 +55,7 @@ extern MagickExport const char *CompositeOperatorToString(const CompositeOperator composite_op) MAGICK_FUNC_CONST; extern MagickExport const char *CompressionTypeToString(const CompressionType compression_type) MAGICK_FUNC_CONST; extern MagickExport const char *ConfirmAccessModeToString(const ConfirmAccessMode access_mode) MAGICK_FUNC_CONST; + extern MagickExport const char *DisposeTypeToString(const DisposeType dispose_type) MAGICK_FUNC_CONST; extern MagickExport const char *GravityTypeToString(const GravityType gravity_type) MAGICK_FUNC_CONST; extern MagickExport const char *EndianTypeToString(const EndianType endian_type) MAGICK_FUNC_CONST; extern MagickExport const char *HighlightStyleToString(const HighlightStyle difference_algorithm) MAGICK_FUNC_CONST; diff -r 9dacc3ab04f2 -r 02742ac3634d www/Changelog.html --- a/www/Changelog.html Thu Nov 04 08:47:57 2021 -0500 +++ b/www/Changelog.html Thu Nov 04 14:31:44 2021 -0500 @@ -37,9 +37,19 @@ <p>2021-11-04 Bob Friesenhahn <<a class="reference external" href="mailto:bfriesen%40simple.dallas.tx.us">bfriesen<span>@</span>simple<span>.</span>dallas<span>.</span>tx<span>.</span>us</a>></p> <blockquote> -* coders/msl.c (MSLEndElement): Ignore imbalanced group +<p>* coders/gif.c (ReadGIFImage): Handle GIF files where the 'opaque' +index matches the number of colors by producing an extra colormap +entry of transparent black. Fixes SourceForge issue 649 "Bug with +gm identify" where the test case produces the error "Invalid +colormap index (index 128 >= 128 colors, /tmp/broken.gif)".</p> +<p>* magick/enum_strings.c (StringToDisposeType): New utility +function to convert a string to a DisposeType. +(DisposeTypeToString) New utility function to convert a +DisposeType to a string.</p> +<p>* coders/msl.c (MSLEndElement): Ignore imbalanced group closure. Fixes oss-fuzz 40680 "graphicsmagick:coder_MSL_fuzzer: -Heap-buffer-overflow in MSLEndElement".</blockquote> +Heap-buffer-overflow in MSLEndElement".</p> +</blockquote> <p>2021-11-03 Bob Friesenhahn <<a class="reference external" href="mailto:bfriesen%40simple.dallas.tx.us">bfriesen<span>@</span>simple<span>.</span>dallas<span>.</span>tx<span>.</span>us</a>></p> <blockquote> <p>* coders/tiff.c (ReadTIFFImage): Make sure that loops using