GraphicsMagick: ReadTIFFImage(): Validate that TIFFGetField() di...

GraphicsMagick Commits <[email protected]>
Newsgroups gmane.comp.video.graphicsmagick.cvs
Message-ID <mailman.11185.1682779564.1789.graphicsmagick-commit@lists.sourceforge.net>
changeset c9b750fbb01f in /hg/GraphicsMagick
details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=c9b750fbb01f
summary: ReadTIFFImage(): Validate that TIFFGetField() did return count and text

diffstat:

 ChangeLog                              |   8 ++++++++
 VisualMagick/installer/inc/version.isx |   4 ++--
 coders/tiff.c                          |  20 ++++++++++----------
 magick/version.h                       |   4 ++--
 www/Changelog.html                     |  10 ++++++++++
 5 files changed, 32 insertions(+), 14 deletions(-)

diffs (101 lines):

diff -r c3f819ecab06 -r c9b750fbb01f ChangeLog
--- a/ChangeLog	Sat Apr 29 08:35:32 2023 -0500
+++ b/ChangeLog	Sat Apr 29 09:45:49 2023 -0500
@@ -1,3 +1,11 @@
+2023-04-29  Bob Friesenhahn  <[email protected]>
+
+	* coders/tiff.c (ReadTIFFImage): Validate that TIFFGetField() did
+	return count and text rather than just relying on its return
+	status.  Addresses SourceForge issue #710 "Undefined behavior
+	while passing a null pointer as an argument to a nonnull
+	function.".
+
 2023-04-26  Fojtik Jaroslav  <[email protected]>
 
 	* VisualMagick/tests/runtest.bat: Added new tests for all possible
diff -r c3f819ecab06 -r c9b750fbb01f VisualMagick/installer/inc/version.isx
--- a/VisualMagick/installer/inc/version.isx	Sat Apr 29 08:35:32 2023 -0500
+++ b/VisualMagick/installer/inc/version.isx	Sat Apr 29 09:45:49 2023 -0500
@@ -10,5 +10,5 @@
 
 #define public MagickPackageName "GraphicsMagick"
 #define public MagickPackageVersion "1.4"
-#define public MagickPackageVersionAddendum ".020230426"
-#define public MagickPackageReleaseDate "snapshot-20230426"
+#define public MagickPackageVersionAddendum ".020230429"
+#define public MagickPackageReleaseDate "snapshot-20230429"
diff -r c3f819ecab06 -r c9b750fbb01f coders/tiff.c
--- a/coders/tiff.c	Sat Apr 29 08:35:32 2023 -0500
+++ b/coders/tiff.c	Sat Apr 29 09:45:49 2023 -0500
@@ -1771,13 +1771,13 @@
 /*
   Copy a possibly unterminated sized string to an image attribute.
 */
-#define CopySizedFieldToAttribute(key,count,text)                     \
-  do                                                                  \
-    {                                                                 \
-      char _attribute[MaxTextExtent];                                 \
-      (void) memcpy(_attribute,text,Min(sizeof(_attribute),count));   \
-      _attribute[Min(sizeof(_attribute)-1,count)]='\0';                \
-      (void) SetImageAttribute(image,key,_attribute);                 \
+#define CopySizedFieldToAttribute(key,count,text)                       \
+  do                                                                    \
+    {                                                                   \
+      char _attribute[MaxTextExtent];                                   \
+      (void) memcpy(_attribute,text,Min(sizeof(_attribute),count));     \
+      _attribute[Min(sizeof(_attribute)-1,count)]='\0';                 \
+      (void) SetImageAttribute(image,key,_attribute);                   \
     } while(0);
 
 
@@ -2345,13 +2345,13 @@
       /*
         "Unsupported" tags return two arguments.
       */
-      if (TIFFGetField(tiff,TIFFTAG_OPIIMAGEID,&count,&text) == 1)
+      if ((TIFFGetField(tiff,TIFFTAG_OPIIMAGEID,&count,&text) == 1) && (count) && (text != (const char*) NULL))
         CopySizedFieldToAttribute("imageid",count,text);
 
-      if (TIFFGetField(tiff,33423,&count,&text) == 1)
+      if ((TIFFGetField(tiff,33423,&count,&text) == 1) && (count) && (text != (const char*) NULL))
         CopySizedFieldToAttribute("kodak-33423",count,text);
 
-      if (TIFFGetField(tiff,36867,&count,&text) == 1)
+      if ((TIFFGetField(tiff,36867,&count,&text) == 1) && (count) && (text != (const char*) NULL))
         CopySizedFieldToAttribute("kodak-36867",count,text);
 
       if ((photometric == PHOTOMETRIC_PALETTE) ||
diff -r c3f819ecab06 -r c9b750fbb01f magick/version.h
--- a/magick/version.h	Sat Apr 29 08:35:32 2023 -0500
+++ b/magick/version.h	Sat Apr 29 09:45:49 2023 -0500
@@ -38,8 +38,8 @@
 #define MagickLibVersion  0x272402
 #define MagickLibVersionText  "1.4"
 #define MagickLibVersionNumber 27,24,2
-#define MagickChangeDate   "20230426"
-#define MagickReleaseDate  "snapshot-20230426"
+#define MagickChangeDate   "20230429"
+#define MagickReleaseDate  "snapshot-20230429"
 
 /*
   The MagickLibInterfaceNewest and MagickLibInterfaceOldest defines
diff -r c3f819ecab06 -r c9b750fbb01f www/Changelog.html
--- a/www/Changelog.html	Sat Apr 29 08:35:32 2023 -0500
+++ b/www/Changelog.html	Sat Apr 29 09:45:49 2023 -0500
@@ -37,6 +37,16 @@
 </div>
 
 <div class="document">
+<p>2023-04-29  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>coders/tiff.c (ReadTIFFImage): Validate that TIFFGetField() did
+return count and text rather than just relying on its return
+status.  Addresses SourceForge issue #710 &quot;Undefined behavior
+while passing a null pointer as an argument to a nonnull
+function.&quot;.</p></li>
+</ul>
+</blockquote>
 <p>2023-04-26  Fojtik Jaroslav  &lt;<a class="reference external" href="mailto:JaFojtik&#37;&#52;&#48;yandex&#46;com">JaFojtik<span>&#64;</span>yandex<span>&#46;</span>com</a>&gt;</p>
 <blockquote>
 <ul class="simple">
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.