37742976 - Catch bad gifs
* A security researcher crafted a gif that would cause the Android Bitmap code to throw an NPE. That would cause messaging to crash when decoding the NPE. The frameworks team is changing the underlying code to throw an OutOfMemoryError instead of a NullPointerException. In order to catch both errors, the code needs to catch Throwable. Test: I added code to GifImageResource.getDrawable to throw a new OutOfMemoryError and then used the debugger to verify it was caught by the new catch Throwable statement. I did the same test with NullPointerException. I tested attaching gif images and sending them to verify the gif path still worked. BUG=37742976 Change-Id: If71a7e65f8c0b083fe6c4b79f78358666338d59d
This commit is contained in:
@@ -58,10 +58,10 @@ public class GifImageResource extends ImageResource {
|
||||
public Drawable getDrawable(Resources resources) {
|
||||
try {
|
||||
return new FrameSequenceDrawable(mFrameSequence);
|
||||
} catch (final Exception e) {
|
||||
// Malicious gif images can make platform throw different kind of exceptions. Catch
|
||||
// them all.
|
||||
LogUtil.e(LogUtil.BUGLE_TAG, "Error getting drawable for GIF", e);
|
||||
} catch (final Throwable t) {
|
||||
// Malicious gif images can make the platform throw different kind of throwables, such
|
||||
// as OutOfMemoryError and NullPointerException. Catch them all.
|
||||
LogUtil.e(LogUtil.BUGLE_TAG, "Error getting drawable for GIF", t);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user