You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ki...@apache.org on 2019/05/15 22:46:37 UTC

[commons-imaging] branch master updated (7d67410 -> f63a13d)

This is an automated email from the ASF dual-hosted git repository.

kinow pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-imaging.git.


    from 7d67410  Remove extra text from license (probably copy/paste error)
     new c14e995  IMAGING-167: Test every operation from below if it would increase ant int value beyond Integer.MAX_VALUE
     new f63a13d  IMAGING-167: changes entry

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/changes/changes.xml                                      |  3 +++
 .../apache/commons/imaging/formats/xpm/XpmImageParser.java   | 12 ++++++++++++
 2 files changed, 15 insertions(+)


[commons-imaging] 01/02: IMAGING-167: Test every operation from below if it would increase ant int value beyond Integer.MAX_VALUE

Posted by ki...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kinow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-imaging.git

commit c14e995dfc8b41b13f83dc7c1a4c1cba2808dec3
Author: Michael Groß <mg...@mgmechanics.de>
AuthorDate: Sun Feb 15 10:52:20 2015 +0100

    IMAGING-167: Test every operation from below if it would increase ant int value beyond Integer.MAX_VALUE
---
 .../apache/commons/imaging/formats/xpm/XpmImageParser.java   | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java b/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java
index 4053357..d6ccda7 100644
--- a/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java
+++ b/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java
@@ -665,6 +665,18 @@ public class XpmImageParser extends ImageParser {
         while (palette == null) {
             palette = paletteFactory.makeExactRgbPaletteSimple(src,
                     hasTransparency ? maxColors - 1 : maxColors);
+            
+            // leave the loop if numbers would go beyond Integer.MAX_VALUE to avoid infinite loops
+            // test every operation from below if it would increase an int value beyond Integer.MAX_VALUE
+            long nextMaxColors = maxColors * WRITE_PALETTE.length;
+            long nextCharsPerPixel = charsPerPixel + 1;
+            if (nextMaxColors > Integer.MAX_VALUE) {
+                throw new ImageWriteException("Xpm: Can't write images with more than Integer.MAX_VALUE colors.");
+            }
+            if (nextCharsPerPixel > Integer.MAX_VALUE) {
+                throw new ImageWriteException("Xpm: Can't write images with more than Integer.MAX_VALUE chars per pixel.");
+            }
+            // the code above makes sure that we never go beyond Integer.MAX_VALUE here
             if (palette == null) {
                 maxColors *= WRITE_PALETTE.length;
                 charsPerPixel++;


[commons-imaging] 02/02: IMAGING-167: changes entry

Posted by ki...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kinow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-imaging.git

commit f63a13d5f7113d29f6e60166e6a70c426d89335f
Author: Bruno P. Kinoshita <ki...@users.noreply.github.com>
AuthorDate: Thu May 16 10:40:31 2019 +1200

    IMAGING-167: changes entry
    
    This closes #6
---
 src/changes/changes.xml | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index ef5af40..0070c41 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -48,6 +48,9 @@ The <action> type attribute can be add,update,fix,remove.
       <action issue="IMAGING-224" dev="kinow" type="fix">
         Fix build errors in Travis
       </action>
+      <action issue="IMAGING-167" dev="kinow" type="fix" due-to="Michael Groß">
+        Possible infinite loop at XpmImageParser::writeImage
+      </action>
     </release>
     <release version="1.0-alpha1" date="2019-04-28" description="First 1.0 alpha release">
       <action issue="IMAGING-199" dev="kinow" type="fix" due-to="Ric Emery">