GraphicsMagick: MogrifyImage() and AdaptiveThresholdImage(): Ver...

GraphicsMagick Commits <[email protected]>
Newsgroups gmane.comp.video.graphicsmagick.cvs
Message-ID <mailman.1708.1678552711.1409.graphicsmagick-commit@lists.sourceforge.net>
changeset 123d0b9535b0 in /hg/GraphicsMagick
details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=123d0b9535b0
summary: MogrifyImage() and AdaptiveThresholdImage(): Verify LAT arguments.

diffstat:

 ChangeLog          |   7 +++++++
 magick/command.c   |  14 ++++++++++----
 magick/effect.c    |   4 ++++
 www/Changelog.html |   5 +++++
 4 files changed, 26 insertions(+), 4 deletions(-)

diffs (69 lines):

diff -r 3b80ce60d73c -r 123d0b9535b0 ChangeLog
--- a/ChangeLog	Sat Mar 11 10:11:26 2023 -0600
+++ b/ChangeLog	Sat Mar 11 10:38:22 2023 -0600
@@ -1,5 +1,12 @@
 2023-03-11  Bob Friesenhahn  <[email protected]>
 
+	* magick/command.c (MogrifyImage): Validate that -lat argument is
+	correctly formed, and that width and height are not zero.
+
+	* magick/effect.c (AdaptiveThresholdImage): Validate that width
+	and height are not zero.  Addresses SourceForge issue #686
+	"Floating Point Exception in gm (magick/effect.c:379)".
+
 	* magick/command.c (MogrifyImage): Report a draw argument error if
 	drawing primitive is NULL.  Addresses SourceForge issue #684
 	"Assertion bug in gm (magick/render.c:2715)"
diff -r 3b80ce60d73c -r 123d0b9535b0 magick/command.c
--- a/magick/command.c	Sat Mar 11 10:11:26 2023 -0600
+++ b/magick/command.c	Sat Mar 11 10:38:22 2023 -0600
@@ -10113,10 +10113,16 @@
             /*
               Local adaptive threshold image.
             */
-            offset=0;
-            height=3;
-            width=3;
-            (void) sscanf(argv[++i],"%lux%lu%lf",&width,&height,&offset);
+            if (sscanf(argv[++i],"%lux%lu%lf",&width,&height,&offset) != 3)
+              {
+                ThrowException(&(*image)->exception,OptionError,MissingArgument,option);
+                break;
+              }
+            if ((width == 0) || (height == 0))
+              {
+                ThrowException3(&(*image)->exception,OptionError,UnableToThresholdImage,NonzeroWidthAndHeightRequired);
+                break;
+              }
             if (strchr(argv[i],'%') != (char *) NULL)
               offset*=((double) MaxRGB/100.0);
             threshold_image=AdaptiveThresholdImage(*image,width,height,offset,
diff -r 3b80ce60d73c -r 123d0b9535b0 magick/effect.c
--- a/magick/effect.c	Sat Mar 11 10:11:26 2023 -0600
+++ b/magick/effect.c	Sat Mar 11 10:38:22 2023 -0600
@@ -161,6 +161,10 @@
   assert(exception != (ExceptionInfo *) NULL);
   assert(exception->signature == MagickSignature);
 
+  if ((width == 0) || (height == 0))
+    ThrowImageException3(OptionError, UnableToThresholdImage,
+                         NonzeroWidthAndHeightRequired);
+
   if ((image->columns < width) || (image->rows < height))
     ThrowImageException3(OptionError, UnableToThresholdImage,
                          ImageSmallerThanRadius);
diff -r 3b80ce60d73c -r 123d0b9535b0 www/Changelog.html
--- a/www/Changelog.html	Sat Mar 11 10:11:26 2023 -0600
+++ b/www/Changelog.html	Sat Mar 11 10:38:22 2023 -0600
@@ -40,6 +40,11 @@
 <p>2023-03-11  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
 <blockquote>
 <ul class="simple">
+<li><p>magick/command.c (MogrifyImage): Validate that -lat argument is
+correctly formed, and that width and height are not zero.</p></li>
+<li><p>magick/effect.c (AdaptiveThresholdImage): Validate that width
+and height are not zero.  Addresses SourceForge issue #686
+&quot;Floating Point Exception in gm (magick/effect.c:379)&quot;.</p></li>
 <li><p>magick/command.c (MogrifyImage): Report a draw argument error if
 drawing primitive is NULL.  Addresses SourceForge issue #684
 &quot;Assertion bug in gm (magick/render.c:2715)&quot;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.