commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r1209945 - /commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/fieldtypes/FieldType.java
Date Sat, 03 Dec 2011 16:38:28 GMT
Author: damjan
Date: Sat Dec  3 16:38:28 2011
New Revision: 1209945

URL: http://svn.apache.org/viewvc?rev=1209945&view=rev
Log:
TIFF parsing should really be done with unsigned ints.
Unfortunately Java doesn't have those,
and Sanselan doesn't use larger ints and zero-extend.
This means Sanselan can't parse files larger than 2GB,
even though the max is 4GB. Fixing this would take more
work, but for now, at least make FieldType's isLocalValue()
treat length as unsigned, so that corrupt lengths
can be caught and ignored early.

Jira issue key: SANSELAN-53


Modified:
    commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/fieldtypes/FieldType.java

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/fieldtypes/FieldType.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/fieldtypes/FieldType.java?rev=1209945&r1=1209944&r2=1209945&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/fieldtypes/FieldType.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/fieldtypes/FieldType.java
Sat Dec  3 16:38:28 2011
@@ -37,7 +37,12 @@ public abstract class FieldType extends 
 
     public boolean isLocalValue(TiffField entry)
     {
-        return ((length > 0) && ((length * entry.length) <= TIFF_ENTRY_MAX_VALUE_LENGTH));
+        // FIXME: we should use unsigned ints for offsets and lengths
+        // when parsing TIFF files. But since we don't,
+        // at least make this method treat length as unsigned,
+        // so that corrupt lengths are caught early.
+        long entryLength = 0xffffffffL & entry.length;
+        return ((length > 0) && ((length * entryLength) <= TIFF_ENTRY_MAX_VALUE_LENGTH));
     }
 
     public int getBytesLength(TiffField entry) throws ImageReadException
@@ -110,4 +115,4 @@ public abstract class FieldType extends 
     public abstract byte[] writeData(Object o, int byteOrder)
             throws ImageWriteException;
 
-}
\ No newline at end of file
+}



Mime
View raw message