[ 
https://issues.apache.org/jira/browse/SANSELAN-47?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12925003#action_12925003
 ] 

Gunduz Can Topal commented on SANSELAN-47:
------------------------------------------

following modifications in  tiiField.fillInValue() fixed this specific issue. 

public void fillInValue(ByteSource byteSource) throws ImageReadException, 
IOException {
        if (!fieldType.isLocalValue(this)) {
            int valueLength = getValueLengthInBytes();

            if (byteSource.getLength() >= (long) valueOffset + valueLength) {
                //if check for bad offsets
                // Debug.debug("fillInValue tag", tag);
                // Debug.debug("fillInValue tagInfo", tagInfo);
                // Debug.debug("fillInValue valueOffset", valueOffset);
                // Debug.debug("fillInValue valueLength", valueLength);

                byte bytes[] = byteSource.getBlock(valueOffset, valueLength);
                setOversizeValue(bytes);
            }
        }
    }

After applying SANSELAN-17 putting a try catch block inside the entry loop in 
readDirectory method and logging the exception without propagating is probably 
going to be better though.

> readDirectory method in TiffReader doesn't gracefully handle exceptions that 
> can be thrown from readbytes methods.
> ------------------------------------------------------------------------------------------------------------------
>
>                 Key: SANSELAN-47
>                 URL: https://issues.apache.org/jira/browse/SANSELAN-47
>             Project: Commons Sanselan
>          Issue Type: Improvement
>         Environment: ubuntu 8.0.4 java 1.6.0_11
>            Reporter: Gunduz Can Topal
>         Attachments: ExifReadOverflow.jpg
>
>
> In case of a corrupt or faulty exif header, we should keep the well formed 
> ones instead of propagating an IOException or an OutofMemory Error to the 
> caller. Attached is a picture taken from an HTC handset, with a faulty exif 
> thumbnail offset, causing an OutOfMemoryException. the patch in SANSELAN-17 
> turns it into an IOException and the good fields are still being lost.
> i.e we should have the following data instead of an exception
> Exif metadata:
> Root: 
>  Modify Date: '2010:10:05 22:51:03'
>  Model: 'HTC Desire'
>  Orientation: 0
>  Unknown Tag (0x9209): 65535
>  Unknown Tag (0x9208): 0
>  Unknown Tag (0x9004): '2010:10:05 22:51:03'
>  Unknown Tag (0x9207): 65535
>  Unknown Tag (0xa403): 65535
>  Image Height: 1552
>  Image Width: 2592
>  Make: 'HTC'
>  Exif Offset: 222
>  Unknown Tag (0xde): null
>  Exif:  (jpegImageData)
>  Preview Image Start: 252
>  Preview Image Length: 0

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to