summaryrefslogtreecommitdiffstats
path: root/gallerycommon
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
commitc83dab412a3babdc6012c95fe1f335cdf3102d7e (patch)
tree71ca79a8b7eced68e243d085d39be3fa6e823c7b /gallerycommon
parent08b5e19052a9e5ee7c53ebf5911f86ffbe8f1f4c (diff)
downloadandroid_packages_apps_Gallery2-c83dab412a3babdc6012c95fe1f335cdf3102d7e.tar.gz
android_packages_apps_Gallery2-c83dab412a3babdc6012c95fe1f335cdf3102d7e.tar.bz2
android_packages_apps_Gallery2-c83dab412a3babdc6012c95fe1f335cdf3102d7e.zip
Handle invalid offset size in ExifParser
Change-Id: I9036f8ea9d7a956a74f4d0cd15ef210dbd9f1de3
Diffstat (limited to 'gallerycommon')
-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 56f722afb..edc8f190f 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);
+ }
}
}
}