GraphicsMagick: IsEventLogged(): New function to report if a par...
GraphicsMagick Commits <[email protected]>
| Newsgroups | gmane.comp.video.graphicsmagick.cvs |
|---|---|
| Message-ID | <mailman.8945.1650747500.2151.graphicsmagick-commit@lists.sourceforge.net> |
changeset f57a5e2fe937 in /hg/GraphicsMagick details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=f57a5e2fe937 summary: IsEventLogged(): New function to report if a particular event will be logged. Use it heavily. diffstat: ChangeLog | 4 + coders/ept.c | 4 +- coders/locale.c | 4 +- coders/pict.c | 20 +++--- coders/tiff.c | 6 +- coders/txt.c | 4 +- magick/analyze.c | 4 +- magick/animate.c | 54 +++++++++--------- magick/attribute.c | 4 +- magick/blob.c | 77 ++++++++++++++------------- magick/constitute.c | 8 +- magick/deprecate.c | 14 ++-- magick/display.c | 72 +++++++++++++------------- magick/effect.c | 4 +- magick/image.c | 44 ++++++++-------- magick/log.c | 139 ++++++++++++++++++++++++++++++-------------------- magick/log.h | 3 +- magick/module.c | 2 +- magick/pixel_cache.c | 13 +++- magick/render.c | 6 +- magick/resize.c | 12 ++-- magick/resource.c | 4 +- magick/segment.c | 4 +- magick/transform.c | 19 +++++- magick/xwindow.c | 14 ++-- www/Changelog.html | 8 ++- www/api/log.html | 110 +++++++++++++++++++++++---------------- 27 files changed, 364 insertions(+), 293 deletions(-) diffs (truncated from 2225 to 500 lines): diff -r 4f4c01ba7cce -r f57a5e2fe937 ChangeLog --- a/ChangeLog Sat Apr 23 13:17:06 2022 -0500 +++ b/ChangeLog Sat Apr 23 15:57:47 2022 -0500 @@ -1,5 +1,9 @@ 2022-04-23 Bob Friesenhahn <[email protected]> + * magick/log.c (IsEventLogged): New function to report if a + particular event will be logged. Us this as much as possible + throughout the software to replace use of IsEventLogging(). + * coders/png.c (ReadMNGImage): Address oss-fuzz 46913 "graphicsmagick:coder_WPG_fuzzer: Indirect-leak in MagickMallocCleared" which was partially pre-existing and diff -r 4f4c01ba7cce -r f57a5e2fe937 coders/ept.c --- a/coders/ept.c Sat Apr 23 13:17:06 2022 -0500 +++ b/coders/ept.c Sat Apr 23 15:57:47 2022 -0500 @@ -1,5 +1,5 @@ /* -% Copyright (C) 2003-2020 GraphicsMagick Group +% Copyright (C) 2003-2022 GraphicsMagick Group % Copyright (C) 2002 ImageMagick Studio % Copyright 1991-1999 E. I. du Pont de Nemours and Company % @@ -555,7 +555,7 @@ assert(image != (Image *) NULL); assert(image->signature == MagickSignature); - logging=IsEventLogging(); + logging=IsEventLogged(CoderEvent); (void) strlcpy(filename,image->filename,MaxTextExtent); (void) strlcpy(ps_filename,image->magick_filename,MaxTextExtent); diff -r 4f4c01ba7cce -r f57a5e2fe937 coders/locale.c --- a/coders/locale.c Sat Apr 23 13:17:06 2022 -0500 +++ b/coders/locale.c Sat Apr 23 15:57:47 2022 -0500 @@ -1,5 +1,5 @@ /* -% Copyright (C) 2003-2020 GraphicsMagick Group +% Copyright (C) 2003-2022 GraphicsMagick Group % Copyright (C) 2002 ImageMagick Studio % % This program is covered by multiple licenses, which are described in @@ -807,7 +807,7 @@ locale[i]=locale[j]; locale[j]=swap; } - if (IsEventLogging()) + if (IsEventLogged(LocaleEvent)) for (i=0; i < count; i++) (void) LogMagickEvent(LocaleEvent,GetMagickModule(),"%.1024s",locale[i]); if (LocaleCompare(image_info->magick,"LOCALEMC") == 0) diff -r 4f4c01ba7cce -r f57a5e2fe937 coders/pict.c --- a/coders/pict.c Sat Apr 23 13:17:06 2022 -0500 +++ b/coders/pict.c Sat Apr 23 15:57:47 2022 -0500 @@ -1,5 +1,5 @@ /* -% Copyright (C) 2003-2020 GraphicsMagick Group +% Copyright (C) 2003-2022 GraphicsMagick Group % Copyright (C) 2002 ImageMagick Studio % Copyright 1991-1999 E. I. du Pont de Nemours and Company % @@ -1315,7 +1315,7 @@ image->columns=frame.right-frame.left; image->rows=frame.bottom-frame.top; - if (IsEventLogging()) + if (IsEventLogged(CoderEvent)) (void) LogMagickEvent(CoderEvent,GetMagickModule(), "Dimensions: %lux%lu",image->columns,image->rows); @@ -1352,12 +1352,12 @@ code=ReadBlobMSBShort(image); /* returns magick_uint16_t */ if (code > 0xa1) { - if (IsEventLogging()) + if (IsEventLogged(CoderEvent)) (void) LogMagickEvent(CoderEvent,GetMagickModule(),"Code %04X:",code); } else { - if (IsEventLogging()) + if (IsEventLogged(CoderEvent)) (void) LogMagickEvent(CoderEvent,GetMagickModule(),"Code %04X %.1024s: %.1024s",code, lookup_string(code_names,sizeof(code_names),code), lookup_string(code_descriptions,sizeof(code_descriptions),code)); @@ -1850,11 +1850,11 @@ } if (tile_image == (Image *) NULL) continue; - if (IsEventLogging()) + if (IsEventLogged(CoderEvent)) (void) LogMagickEvent(CoderEvent,GetMagickModule(), "Tile Dimensions: %lux%lu", tile_image->columns,tile_image->rows); - if (IsEventLogging()) + if (IsEventLogged(CoderEvent)) (void) LogMagickEvent(CoderEvent,GetMagickModule(), "Tile Resolution: %gx%g %s", tile_image->x_resolution, @@ -1866,18 +1866,18 @@ "pixels")); FormatString(geometry,"%lux%lu",Max(image->columns,tile_image->columns), Max(image->rows,tile_image->rows)); - if (IsEventLogging()) + if (IsEventLogged(CoderEvent)) (void) LogMagickEvent(CoderEvent,GetMagickModule(), "Tile Transform %lux%lu ==> %s", tile_image->columns,tile_image->rows, geometry); if (TransformImage(&tile_image,(char *) NULL,geometry) != MagickPass) { - if (IsEventLogging()) + if (IsEventLogged(CoderEvent)) (void) LogMagickEvent(CoderEvent,GetMagickModule(), "Tile transform failed!"); } - if (IsEventLogging()) + if (IsEventLogged(CoderEvent)) (void) LogMagickEvent(CoderEvent,GetMagickModule(), "Tile Composite of %lux%lu on canvas %lux%lu at +%u,+%u", tile_image->columns,tile_image->rows, @@ -1885,7 +1885,7 @@ if (CompositeImage(image,CopyCompositeOp,tile_image,frame.left, frame.right) != MagickPass) { - if (IsEventLogging()) + if (IsEventLogged(CoderEvent)) (void) LogMagickEvent(CoderEvent,GetMagickModule(), "Tile composite failed!"); } diff -r 4f4c01ba7cce -r f57a5e2fe937 coders/tiff.c --- a/coders/tiff.c Sat Apr 23 13:17:06 2022 -0500 +++ b/coders/tiff.c Sat Apr 23 15:57:47 2022 -0500 @@ -1,5 +1,5 @@ /* -% Copyright (C) 2003 - 2021 GraphicsMagick Group +% Copyright (C) 2003 - 2022 GraphicsMagick Group % Copyright (C) 2002 ImageMagick Studio % Copyright 1991-1999 E. I. du Pont de Nemours and Company % @@ -1883,7 +1883,7 @@ assert(exception != (ExceptionInfo *) NULL); assert(exception->signature == MagickSignature); - logging=IsEventLogging(); + logging=IsEventLogged(CoderEvent); image=AllocateImage(image_info); more_frames=MagickFalse; status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); @@ -4365,7 +4365,7 @@ assert(image != (Image *) NULL); assert(image->signature == MagickSignature); image_list_length=GetImageListLength(image); - logging=IsEventLogging(); + logging=IsEventLogged(CoderEvent); status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception); if (status == MagickFail) ThrowWriterException(FileOpenError,UnableToOpenFile,image); diff -r 4f4c01ba7cce -r f57a5e2fe937 coders/txt.c --- a/coders/txt.c Sat Apr 23 13:17:06 2022 -0500 +++ b/coders/txt.c Sat Apr 23 15:57:47 2022 -0500 @@ -1,5 +1,5 @@ /* -% Copyright (C) 2003-2020 GraphicsMagick Group +% Copyright (C) 2003-2022 GraphicsMagick Group % Copyright (C) 2002 ImageMagick Studio % Copyright 1991-1999 E. I. du Pont de Nemours and Company % @@ -328,7 +328,7 @@ assert(exception != (ExceptionInfo *) NULL); assert(exception->signature == MagickSignature); - logging = IsEventLogging(); + logging = IsEventLogged(CoderEvent); image=AllocateImage(image_info); status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); if (status == False) diff -r 4f4c01ba7cce -r f57a5e2fe937 magick/analyze.c --- a/magick/analyze.c Sat Apr 23 13:17:06 2022 -0500 +++ b/magick/analyze.c Sat Apr 23 15:57:47 2022 -0500 @@ -1,5 +1,5 @@ /* -% Copyright (C) 2003 - 2019 GraphicsMagick Group +% Copyright (C) 2003 - 2022 GraphicsMagick Group % Copyright (C) 2003 ImageMagick Studio % Copyright 1991-1999 E. I. du Pont de Nemours and Company % @@ -253,7 +253,7 @@ bounds.x=0; bounds.y=0; } - if (image->logging) + if (IsEventLogged(TransformEvent)) (void) LogMagickEvent(TransformEvent,GetMagickModule(), "Bounding Box: %lux%lu%+ld%+ld", bounds.width, bounds.height, bounds.x, bounds.y); diff -r 4f4c01ba7cce -r f57a5e2fe937 magick/animate.c --- a/magick/animate.c Sat Apr 23 13:17:06 2022 -0500 +++ b/magick/animate.c Sat Apr 23 15:57:47 2022 -0500 @@ -1,5 +1,5 @@ /* -% Copyright (C) 2003-2019 GraphicsMagick Group +% Copyright (C) 2003-2022 GraphicsMagick Group % Copyright (C) 2002 ImageMagick Studio % Copyright 1991-1999 E. I. du Pont de Nemours and Company % @@ -825,7 +825,7 @@ MagickFatalError(XServerFatalError,UnableToCreateXImage,(char *) NULL); window_info.x=0; window_info.y=0; - if (IsEventLogging()) + if (IsEventLogged(X11Event)) { (void) LogMagickEvent(X11Event,GetMagickModule(), "Image: %.1024s[%lu] %lux%lu ",image_list[0]->filename, @@ -941,7 +941,7 @@ (unsigned int) image_list[scene]->rows); if (status == False) MagickFatalError(XServerFatalError,UnableToCreateXImage,(char *) NULL); - if (IsEventLogging()) + if (IsEventLogged(X11Event)) { (void) LogMagickEvent(X11Event,GetMagickModule(), "Image: [%lu] %.1024s %lux%lu ",image_list[scene]->scene, @@ -1417,7 +1417,7 @@ (display_image->rows < image_list[scene]->rows)) display_image=image_list[scene]; } - if (IsEventLogging()) + if (IsEventLogged(X11Event)) { (void) LogMagickEvent(X11Event,GetMagickModule(), "Image: %.1024s[%lu] %lux%lu ",display_image->filename, @@ -1443,7 +1443,7 @@ manager_hints->initial_state=WithdrawnState; MagickXMakeWindow(display,root_window,argv,argc,class_hints,manager_hints, &windows->context); - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(), "Window id: 0x%lx (context)",windows->context.id); context_values.background=pixel->background_color.pixel; @@ -1494,7 +1494,7 @@ manager_hints->initial_state=IconicState; MagickXMakeWindow(display,root_window,argv,argc,class_hints,manager_hints, &windows->icon); - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(),"Window id: 0x%lx (icon)", windows->icon.id); /* @@ -1590,7 +1590,7 @@ resource_info->iconic ? IconicState : NormalState; MagickXMakeWindow(display,root_window,argv,argc,class_hints,manager_hints, &windows->backdrop); - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(), "Window id: 0x%lx (backdrop)",windows->backdrop.id); (void) XMapWindow(display,windows->backdrop.id); @@ -1626,7 +1626,7 @@ manager_hints->flags|=(unsigned int) WindowGroupHint; manager_hints->window_group=windows->group_leader.id; (void) XSelectInput(display,windows->group_leader.id,StructureNotifyMask); - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(), "Window id: 0x%lx (group leader)",windows->group_leader.id); } @@ -1638,7 +1638,7 @@ if (windows->group_leader.id != (Window) NULL) (void) XSetTransientForHint(display,windows->image.id, windows->group_leader.id); - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(),"Window id: 0x%lx (image)", windows->image.id); /* @@ -1669,7 +1669,7 @@ (void) XSetTransientForHint(display,windows->info.id,windows->image.id); if (windows->image.mapped) (void) XWithdrawWindow(display,windows->info.id,windows->info.screen); - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(),"Window id: 0x%lx (info)", windows->info.id); /* @@ -1698,7 +1698,7 @@ windows->command.highlight_stipple=windows->info.highlight_stipple; windows->command.shadow_stipple=windows->info.shadow_stipple; (void) XSetTransientForHint(display,windows->command.id,windows->image.id); - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(),"Window id: 0x%lx (command)", windows->command.id); /* @@ -1731,7 +1731,7 @@ windows->widget.highlight_stipple=windows->info.highlight_stipple; windows->widget.shadow_stipple=windows->info.shadow_stipple; (void) XSetTransientForHint(display,windows->widget.id,windows->image.id); - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(),"Window id: 0x%lx (widget)", windows->widget.id); /* @@ -1760,7 +1760,7 @@ windows->popup.highlight_stipple=windows->info.highlight_stipple; windows->popup.shadow_stipple=windows->info.shadow_stipple; (void) XSetTransientForHint(display,windows->popup.id,windows->image.id); - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(),"Window id: 0x%lx (pop up)", windows->popup.id); if (!windows->image.mapped || (windows->backdrop.id != (Window) NULL)) @@ -1827,7 +1827,7 @@ (unsigned int) image_list[scene]->rows); if (status == False) MagickFatalError(XServerFatalError,UnableToCreateXImage,(char *) NULL); - if (IsEventLogging()) + if (IsEventLogged(X11Event)) { (void) LogMagickEvent(X11Event,GetMagickModule(), "Image: [%lu] %.1024s %lux%lu ",image_list[scene]->scene, @@ -2048,7 +2048,7 @@ { case ButtonPress: { - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(), "Button Press: 0x%lx %u +%d+%d",event.xbutton.window, event.xbutton.button,event.xbutton.x,event.xbutton.y); @@ -2091,7 +2091,7 @@ } case ButtonRelease: { - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(), "Button Release: 0x%lx %u +%d+%d",event.xbutton.window, event.xbutton.button,event.xbutton.x,event.xbutton.y); @@ -2099,7 +2099,7 @@ } case ClientMessage: { - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(), "Client Message: 0x%lx 0x%lx %d 0x%lx",event.xclient.window, event.xclient.message_type,event.xclient.format,(unsigned long) @@ -2226,7 +2226,7 @@ } case ConfigureNotify: { - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(), "Configure Notify: 0x%lx %dx%d+%d+%d %d",event.xconfigure.window, event.xconfigure.width,event.xconfigure.height,event.xconfigure.x, @@ -2290,7 +2290,7 @@ /* Group leader has exited. */ - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(),"Destroy Notify: 0x%lx", event.xdestroywindow.window); if (event.xdestroywindow.window == windows->group_leader.id) @@ -2316,7 +2316,7 @@ } case Expose: { - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(), "Expose: 0x%lx %dx%d+%d+%d",event.xexpose.window, event.xexpose.width,event.xexpose.height,event.xexpose.x, @@ -2350,7 +2350,7 @@ length=XLookupString((XKeyEvent *) &event.xkey,command,sizeof(command), &key_symbol,(XComposeStatus *) NULL); *(command+length)='\0'; - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(),"Key press: 0x%lx (%c)", key_symbol,*command); command_type=NullCommand; @@ -2421,7 +2421,7 @@ */ (void) XLookupString((XKeyEvent *) &event.xkey,command,sizeof(command), &key_symbol,(XComposeStatus *) NULL); - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(), "Key release: 0x%lx (%c)",key_symbol,*command); break; @@ -2442,7 +2442,7 @@ } case MapNotify: { - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(),"Map Notify: 0x%lx", event.xmap.window); if (event.xmap.window == windows->backdrop.id) @@ -2528,7 +2528,7 @@ after, length; - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(), "Property Notify: 0x%lx 0x%lx %d",event.xproperty.window, event.xproperty.atom,event.xproperty.state); @@ -2555,7 +2555,7 @@ } case ReparentNotify: { - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(), "Reparent Notify: 0x%lx=>0x%lx",event.xreparent.parent, event.xreparent.window); @@ -2563,7 +2563,7 @@ } case UnmapNotify: { - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(),"Unmap Notify: 0x%lx", event.xunmap.window); if (event.xunmap.window == windows->backdrop.id) @@ -2616,7 +2616,7 @@ } default: { - if (IsEventLogging()) + if (IsEventLogged(X11Event)) (void) LogMagickEvent(X11Event,GetMagickModule(),"Event type: %d", event.type); break; diff -r 4f4c01ba7cce -r f57a5e2fe937 magick/attribute.c --- a/magick/attribute.c Sat Apr 23 13:17:06 2022 -0500 +++ b/magick/attribute.c Sat Apr 23 15:57:47 2022 -0500 @@ -1,5 +1,5 @@ /* -% Copyright (C) 2003-2019 GraphicsMagick Group +% Copyright (C) 2003-2022 GraphicsMagick Group % Copyright (C) 2002 ImageMagick Studio % % This program is covered by multiple licenses, which are described in @@ -1621,7 +1621,7 @@ debug=MagickFalse; assert((ArraySize(format_bytes)-1) == EXIF_NUM_FORMATS); - logging=IsEventLogging(); + logging=IsEventLogged(TransformEvent); { const char * env_value; diff -r 4f4c01ba7cce -r f57a5e2fe937 magick/blob.c --- a/magick/blob.c Sat Apr 23 13:17:06 2022 -0500 +++ b/magick/blob.c Sat Apr 23 15:57:47 2022 -0500 @@ -120,6 +120,7 @@ MagickBool exempt, /* True if file descriptor should not be closed.*/ + logging, /* BlobEvent logging is enabled */ temporary; /* Associated file is a temporary file */ int @@ -336,7 +337,7 @@ blob->quantum<<=1; blob->extent+=length+blob->quantum; #if 0 - if (image->logging) + if (blob->logging) (void) LogMagickEvent(BlobEvent,GetMagickModule(), "MagickReallocMemory blob->data=%p," " blob->extent=%" MAGICK_SIZE_T_F "u", @@ -347,7 +348,7 @@ if (blob->data == (unsigned char *) NULL) { #if 0 - if (image->logging) + if (blob->logging) (void) LogMagickEvent(BlobEvent,GetMagickModule(), "MagickReallocMemory failed! Detatching Blob..."); #endif @@ -548,7 +549,7 @@ status=MagickFail; } } - if (image->logging) + if (blob->logging) (void) LogMagickEvent(BlobEvent,GetMagickModule(), "Request to reserve %" MAGICK_OFF_F "u output bytes %s", size, @@ -949,7 +950,7 @@ if ((blob == (BlobInfo *) NULL) || (blob->type == UndefinedStream)) return MagickPass;