diff options
author | Brint E. Kriebel <bekit@cyngn.com> | 2014-11-18 15:46:38 -0800 |
---|---|---|
committer | Brint E. Kriebel <bekit@cyngn.com> | 2014-11-18 15:46:38 -0800 |
commit | c9be98c6f204067dcedce3807e8f6de65153fee3 (patch) | |
tree | 5204073220a6f20c4b9bac67c04594cb516c433b | |
parent | 64a4d21672357e08d9ad76014b68267bd1c0adec (diff) | |
parent | 718ef54f748fd12d9b3672e2ff3840370df3df1e (diff) | |
download | android_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 |
Merge branch 'cm-11.0' into stable/cm-11.0cm-11.0-XNPH05Q-tomato-9828f8e9cccm-11.0-XNPH05Q-bacon-5229c4ef56stable/cm-11.0-XNF9Xstable/cm-11.0-XNF8Ystable/cm-11.0shipping/cm-11.0
Change-Id: I04f0875a14b8c13128985456f4039a4d64168a53
-rw-r--r-- | src/images/SkImageDecoder_libico.cpp | 12 |
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)) { |