summaryrefslogtreecommitdiffstats
path: root/gallerycommon/src/com/android/gallery3d
diff options
context:
space:
mode:
authorEarl Ou <shunhsingou@google.com>2012-10-18 19:13:37 +0800
committerEarl Ou <shunhsingou@google.com>2012-10-24 11:13:21 +0800
commit8c90c11b41e1450f86f8ed4b91a2a49f618a76c6 (patch)
tree0c6e2d557fa11c989fd58b635f45e974e85eae21 /gallerycommon/src/com/android/gallery3d
parent9cf0bba7e618f9a4831c3b02e255997191a50b5d (diff)
downloadandroid_packages_apps_Snap-8c90c11b41e1450f86f8ed4b91a2a49f618a76c6.zip
android_packages_apps_Snap-8c90c11b41e1450f86f8ed4b91a2a49f618a76c6.tar.gz
android_packages_apps_Snap-8c90c11b41e1450f86f8ed4b91a2a49f618a76c6.tar.bz2
Handle invalid offset size in ExifParser
Change-Id: I9036f8ea9d7a956a74f4d0cd15ef210dbd9f1de3
Diffstat (limited to 'gallerycommon/src/com/android/gallery3d')
-rw-r--r--gallerycommon/src/com/android/gallery3d/exif/ExifParser.java20
1 files changed, 17 insertions, 3 deletions
diff --git a/gallerycommon/src/com/android/gallery3d/exif/ExifParser.java b/gallerycommon/src/com/android/gallery3d/exif/ExifParser.java
index 56f722a..edc8f19 100644
--- a/gallerycommon/src/com/android/gallery3d/exif/ExifParser.java
+++ b/gallerycommon/src/com/android/gallery3d/exif/ExifParser.java
@@ -16,6 +16,8 @@
package com.android.gallery3d.exif;
+import android.util.Log;
+
import java.io.DataInputStream;
import java.io.EOFException;
import java.io.IOException;
@@ -64,6 +66,7 @@ import java.util.TreeMap;
* </pre>
*/
public class ExifParser {
+ private static final String TAG = "ExifParser";
/**
* When the parser reaches a new IFD area. Call
* {@link #getCurrentIfd()} to know which IFD we are in.
@@ -230,17 +233,28 @@ public class ExifParser {
}
return EVENT_NEW_TAG;
} else if (offset == endOfTags) {
- long ifdOffset = readUnsignedLong();
// There is a link to ifd1 at the end of ifd0
if (mIfdType == IfdId.TYPE_IFD_0) {
+ long ifdOffset = readUnsignedLong();
if (isIfdRequested(IfdId.TYPE_IFD_1) || isThumbnailRequested()) {
if (ifdOffset != 0) {
registerIfd(IfdId.TYPE_IFD_1, ifdOffset);
}
}
} else {
- if (ifdOffset != 0) {
- throw new ExifInvalidFormatException("Invalid link to next IFD");
+ int offsetSize = 4;
+ // Some camera models use invalid length of the offset
+ if (mCorrespondingEvent.size() > 0) {
+ offsetSize = mCorrespondingEvent.firstEntry().getKey() -
+ mTiffStream.getReadByteCount();
+ }
+ if (offsetSize < 4) {
+ Log.w(TAG, "Invalid size of link to next IFD: " + offsetSize);
+ } else {
+ long ifdOffset = readUnsignedLong();
+ if (ifdOffset != 0) {
+ Log.w(TAG, "Invalid link to next IFD: " + ifdOffset);
+ }
}
}
}