GraphicsMagick: JP2: BlobRead()/BlobWrite(), if value does not f...

GraphicsMagick Commits <[email protected]> Sun, 17 Sep 2023 14:01:59 -0500
Newsgroups gmane.comp.video.graphicsmagick.cvs
Message-ID <mailman.1301.1694977328.7975.graphicsmagick-commit@lists.sourceforge.net>
changeset 19d29252e157 in /hg/GraphicsMagick
details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=19d29252e157
summary: JP2: BlobRead()/BlobWrite(), if value does not fit in int, then return 0

diffstat:

 ChangeLog          |   5 +++++
 coders/jp2.c       |  12 ++++++++++++
 www/Changelog.html |   4 ++++
 3 files changed, 21 insertions(+), 0 deletions(-)

diffs (59 lines):

diff -r 39266dbb994f -r 19d29252e157 ChangeLog
--- a/ChangeLog	Sun Sep 17 13:40:33 2023 -0500
+++ b/ChangeLog	Sun Sep 17 14:01:55 2023 -0500
@@ -1,5 +1,10 @@
 2023-09-17  Bob Friesenhahn  <[email protected]>
 
+	* coders/jp2.c (BlobRead): For old libJasper, return 0 for size
+	value if the actual value does not fit in an 'int'.
+	* coders/jp2.c (BlobWrite): For old libJasper, return 0 for size
+	value if the actual value does not fit in an 'int'.
+
 	* magick/command.c (MagickCommand): Eliminate duplicate utility
 	name output in error messages when utility is executed via a
 	magick compatibility link.  For example via symbolic link from
diff -r 39266dbb994f -r 19d29252e157 coders/jp2.c
--- a/coders/jp2.c	Sun Sep 17 13:40:33 2023 -0500
+++ b/coders/jp2.c	Sun Sep 17 14:01:55 2023 -0500
@@ -354,7 +354,13 @@
     *source = (StreamManager *) obj;
 
   count=ReadBlob(source->image,(size_t) cnt,(void *) buf);
+#if defined(HAVE_JAS_STREAM_IO_V3)
   return (count);
+#else
+  if ((size_t)((int) count) != count)
+    count = 0;
+  return ((int) count);
+#endif
 }
 
 /* Write characters to a file object. */
@@ -372,7 +378,13 @@
     *source = (StreamManager *) obj;
 
   count=WriteBlob(source->image,(size_t) cnt,(void *) buf);
+#if defined(HAVE_JAS_STREAM_IO_V3)
   return(count);
+#else
+  if ((size_t)((int) count) != count)
+    count = 0;
+  return ((int) count);
+#endif
 }
 
 /* Set the position for a file object. */
diff -r 39266dbb994f -r 19d29252e157 www/Changelog.html
--- a/www/Changelog.html	Sun Sep 17 13:40:33 2023 -0500
+++ b/www/Changelog.html	Sun Sep 17 14:01:55 2023 -0500
@@ -40,6 +40,10 @@
 <p>2023-09-17  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/jp2.c (BlobRead): For old libJasper, return 0 for size
+value if the actual value does not fit in an 'int'.</p></li>
+<li><p>coders/jp2.c (BlobWrite): For old libJasper, return 0 for size
+value if the actual value does not fit in an 'int'.</p></li>
 <li><p>magick/command.c (MagickCommand): Eliminate duplicate utility
 name output in error messages when utility is executed via a
 magick compatibility link.  For example via symbolic link from