Loading media/java/android/media/ExifInterface.java +42 −21 Original line number Diff line number Diff line Loading @@ -82,7 +82,7 @@ import java.util.regex.Pattern; */ public class ExifInterface { private static final String TAG = "ExifInterface"; private static final boolean DEBUG = false; private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); // The Exif tag names. See Tiff 6.0 Section 3 and Section 8. /** Type is String. */ Loading Loading @@ -1605,12 +1605,15 @@ public class ExifInterface { || exifTag.primaryFormat == IFD_FORMAT_STRING) { dataFormat = exifTag.primaryFormat; } else { Log.w(TAG, "Given tag (" + tag + ") value didn't match with one of expected " if (DEBUG) { Log.d(TAG, "Given tag (" + tag + ") value didn't match with one of expected " + "formats: " + IFD_FORMAT_NAMES[exifTag.primaryFormat] + (exifTag.secondaryFormat == -1 ? "" : ", " + IFD_FORMAT_NAMES[exifTag.secondaryFormat]) + " (guess: " + IFD_FORMAT_NAMES[guess.first] + (guess.second == -1 ? "" : ", " + IFD_FORMAT_NAMES[guess.second]) + ")"); } continue; } switch (dataFormat) { Loading Loading @@ -1688,7 +1691,9 @@ public class ExifInterface { break; } default: Log.w(TAG, "Data format isn't one of expected formats: " + dataFormat); if (DEBUG) { Log.d(TAG, "Data format isn't one of expected formats: " + dataFormat); } continue; } } Loading Loading @@ -1790,7 +1795,7 @@ public class ExifInterface { // ExifInterface. mIsSupportedFile = false; if (DEBUG) { Log.w(TAG, "Invalid image: ExifInterface got an unsupported image format file" Log.d(TAG, "Invalid image: ExifInterface got an unsupported image format file" + "(ExifInterface supports JPEG and some RAW image formats only) " + "or a corrupted JPEG file to ExifInterface.", e); } Loading Loading @@ -3183,14 +3188,20 @@ public class ExifInterface { long byteCount = 0; boolean valid = false; if (tag == null) { Log.w(TAG, "Skip the tag entry since tag number is not defined: " + tagNumber); if (DEBUG) { Log.d(TAG, "Skip the tag entry since tag number is not defined: " + tagNumber); } } else if (dataFormat <= 0 || dataFormat >= IFD_FORMAT_BYTES_PER_FORMAT.length) { Log.w(TAG, "Skip the tag entry since data format is invalid: " + dataFormat); if (DEBUG) { Log.d(TAG, "Skip the tag entry since data format is invalid: " + dataFormat); } } else { byteCount = (long) numberOfComponents * IFD_FORMAT_BYTES_PER_FORMAT[dataFormat]; if (byteCount < 0 || byteCount > Integer.MAX_VALUE) { Log.w(TAG, "Skip the tag entry since the number of components is invalid: " if (DEBUG) { Log.d(TAG, "Skip the tag entry since the number of components is invalid: " + numberOfComponents); } } else { valid = true; } Loading Loading @@ -3239,7 +3250,9 @@ public class ExifInterface { dataInputStream.seek(offset); } else { // Skip if invalid data offset. Log.w(TAG, "Skip the tag entry since data offset is invalid: " + offset); if (DEBUG) { Log.d(TAG, "Skip the tag entry since data offset is invalid: " + offset); } dataInputStream.seek(nextEntryOffset); continue; } Loading Loading @@ -3289,11 +3302,15 @@ public class ExifInterface { dataInputStream.seek(offset); readImageFileDirectory(dataInputStream, nextIfdType); } else { Log.w(TAG, "Skip jump into the IFD since it has already been read: " if (DEBUG) { Log.d(TAG, "Skip jump into the IFD since it has already been read: " + "IfdType " + nextIfdType + " (at " + offset + ")"); } } } else { Log.w(TAG, "Skip jump into the IFD since its offset is invalid: " + offset); if (DEBUG) { Log.d(TAG, "Skip jump into the IFD since its offset is invalid: " + offset); } } dataInputStream.seek(nextEntryOffset); Loading Loading @@ -3348,15 +3365,19 @@ public class ExifInterface { readImageFileDirectory(dataInputStream, IFD_TYPE_PREVIEW); } } else { Log.w(TAG, "Stop reading file since re-reading an IFD may cause an " if (DEBUG) { Log.d(TAG, "Stop reading file since re-reading an IFD may cause an " + "infinite loop: " + nextIfdOffset); } } } else { Log.w(TAG, "Stop reading file since a wrong offset may cause an infinite loop: " if (DEBUG) { Log.d(TAG, "Stop reading file since a wrong offset may cause an infinite loop: " + nextIfdOffset); } } } } /** * JPEG compressed images do not contain IMAGE_LENGTH & IMAGE_WIDTH tags. Loading Loading
media/java/android/media/ExifInterface.java +42 −21 Original line number Diff line number Diff line Loading @@ -82,7 +82,7 @@ import java.util.regex.Pattern; */ public class ExifInterface { private static final String TAG = "ExifInterface"; private static final boolean DEBUG = false; private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); // The Exif tag names. See Tiff 6.0 Section 3 and Section 8. /** Type is String. */ Loading Loading @@ -1605,12 +1605,15 @@ public class ExifInterface { || exifTag.primaryFormat == IFD_FORMAT_STRING) { dataFormat = exifTag.primaryFormat; } else { Log.w(TAG, "Given tag (" + tag + ") value didn't match with one of expected " if (DEBUG) { Log.d(TAG, "Given tag (" + tag + ") value didn't match with one of expected " + "formats: " + IFD_FORMAT_NAMES[exifTag.primaryFormat] + (exifTag.secondaryFormat == -1 ? "" : ", " + IFD_FORMAT_NAMES[exifTag.secondaryFormat]) + " (guess: " + IFD_FORMAT_NAMES[guess.first] + (guess.second == -1 ? "" : ", " + IFD_FORMAT_NAMES[guess.second]) + ")"); } continue; } switch (dataFormat) { Loading Loading @@ -1688,7 +1691,9 @@ public class ExifInterface { break; } default: Log.w(TAG, "Data format isn't one of expected formats: " + dataFormat); if (DEBUG) { Log.d(TAG, "Data format isn't one of expected formats: " + dataFormat); } continue; } } Loading Loading @@ -1790,7 +1795,7 @@ public class ExifInterface { // ExifInterface. mIsSupportedFile = false; if (DEBUG) { Log.w(TAG, "Invalid image: ExifInterface got an unsupported image format file" Log.d(TAG, "Invalid image: ExifInterface got an unsupported image format file" + "(ExifInterface supports JPEG and some RAW image formats only) " + "or a corrupted JPEG file to ExifInterface.", e); } Loading Loading @@ -3183,14 +3188,20 @@ public class ExifInterface { long byteCount = 0; boolean valid = false; if (tag == null) { Log.w(TAG, "Skip the tag entry since tag number is not defined: " + tagNumber); if (DEBUG) { Log.d(TAG, "Skip the tag entry since tag number is not defined: " + tagNumber); } } else if (dataFormat <= 0 || dataFormat >= IFD_FORMAT_BYTES_PER_FORMAT.length) { Log.w(TAG, "Skip the tag entry since data format is invalid: " + dataFormat); if (DEBUG) { Log.d(TAG, "Skip the tag entry since data format is invalid: " + dataFormat); } } else { byteCount = (long) numberOfComponents * IFD_FORMAT_BYTES_PER_FORMAT[dataFormat]; if (byteCount < 0 || byteCount > Integer.MAX_VALUE) { Log.w(TAG, "Skip the tag entry since the number of components is invalid: " if (DEBUG) { Log.d(TAG, "Skip the tag entry since the number of components is invalid: " + numberOfComponents); } } else { valid = true; } Loading Loading @@ -3239,7 +3250,9 @@ public class ExifInterface { dataInputStream.seek(offset); } else { // Skip if invalid data offset. Log.w(TAG, "Skip the tag entry since data offset is invalid: " + offset); if (DEBUG) { Log.d(TAG, "Skip the tag entry since data offset is invalid: " + offset); } dataInputStream.seek(nextEntryOffset); continue; } Loading Loading @@ -3289,11 +3302,15 @@ public class ExifInterface { dataInputStream.seek(offset); readImageFileDirectory(dataInputStream, nextIfdType); } else { Log.w(TAG, "Skip jump into the IFD since it has already been read: " if (DEBUG) { Log.d(TAG, "Skip jump into the IFD since it has already been read: " + "IfdType " + nextIfdType + " (at " + offset + ")"); } } } else { Log.w(TAG, "Skip jump into the IFD since its offset is invalid: " + offset); if (DEBUG) { Log.d(TAG, "Skip jump into the IFD since its offset is invalid: " + offset); } } dataInputStream.seek(nextEntryOffset); Loading Loading @@ -3348,15 +3365,19 @@ public class ExifInterface { readImageFileDirectory(dataInputStream, IFD_TYPE_PREVIEW); } } else { Log.w(TAG, "Stop reading file since re-reading an IFD may cause an " if (DEBUG) { Log.d(TAG, "Stop reading file since re-reading an IFD may cause an " + "infinite loop: " + nextIfdOffset); } } } else { Log.w(TAG, "Stop reading file since a wrong offset may cause an infinite loop: " if (DEBUG) { Log.d(TAG, "Stop reading file since a wrong offset may cause an infinite loop: " + nextIfdOffset); } } } } /** * JPEG compressed images do not contain IMAGE_LENGTH & IMAGE_WIDTH tags. Loading