aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrint E. Kriebel <bekit@cyngn.com>2014-11-18 15:46:38 -0800
committerBrint E. Kriebel <bekit@cyngn.com>2014-11-18 15:46:38 -0800
commitc9be98c6f204067dcedce3807e8f6de65153fee3 (patch)
tree5204073220a6f20c4b9bac67c04594cb516c433b
parent64a4d21672357e08d9ad76014b68267bd1c0adec (diff)
parent718ef54f748fd12d9b3672e2ff3840370df3df1e (diff)
downloadandroid_external_skia-stable/cm-11.0-XNF8Y.tar.gz
android_external_skia-stable/cm-11.0-XNF8Y.tar.bz2
android_external_skia-stable/cm-11.0-XNF8Y.zip
Change-Id: I04f0875a14b8c13128985456f4039a4d64168a53
-rw-r--r--src/images/SkImageDecoder_libico.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/images/SkImageDecoder_libico.cpp b/src/images/SkImageDecoder_libico.cpp
index 2b65a36c76..a7a6f14b13 100644
--- a/src/images/SkImageDecoder_libico.cpp
+++ b/src/images/SkImageDecoder_libico.cpp
@@ -148,16 +148,22 @@ bool SkICOImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode)
//int reservedToo = readByte(buf, 9 + choice*16); //0
//int planes = read2Bytes(buf, 10 + choice*16); //1 - but often 0
//int fakeBitCount = read2Bytes(buf, 12 + choice*16); //should be real - usually 0
- int size = read4Bytes(buf, 14 + choice*16); //matters?
- int offset = read4Bytes(buf, 18 + choice*16);
- if ((size_t)(offset + size) > length)
+ const size_t size = read4Bytes(buf, 14 + choice*16); //matters?
+ const size_t offset = read4Bytes(buf, 18 + choice*16);
+ // promote the sum to 64-bits to avoid overflow
+ if (((uint64_t)offset + size) > length) {
return false;
+ }
// Check to see if this is a PNG image inside the ICO
{
SkMemoryStream subStream(buf + offset, size, false);
SkAutoTDelete<SkImageDecoder> otherDecoder(SkImageDecoder::Factory(&subStream));
if (otherDecoder.get() != NULL) {
+ // Disallow nesting ICO files within one another
+ if (otherDecoder->getFormat() == SkImageDecoder::kICO_Format) {
+ return false;
+ }
// Set fields on the other decoder to be the same as this one.
this->copyFieldsToOther(otherDecoder.get());
if(otherDecoder->decode(&subStream, bm, this->getDefaultPref(), mode)) {