Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id F2048794E for ; Sat, 3 Dec 2011 16:38:52 +0000 (UTC) Received: (qmail 66861 invoked by uid 500); 3 Dec 2011 16:38:52 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 66790 invoked by uid 500); 3 Dec 2011 16:38:52 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 66783 invoked by uid 99); 3 Dec 2011 16:38:52 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 03 Dec 2011 16:38:52 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 03 Dec 2011 16:38:50 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 6322423889FD for ; Sat, 3 Dec 2011 16:38:28 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@commons.apache.org From: damjan@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111203163828.6322423889FD@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 +}