Skip to content

Commit 1168aa4

Browse files
drWulfandi34
authored andcommitted
Prevent malformed ICO files from recursively decoding
R=reed@google.com, scroggo@google.com Author: djsollen@google.com Review URL: https://codereview.chromium.org/511453002 bug:17265466,17262540 Change-Id: I128b54c74d75b7afca20e47e6650c500278c5adc
1 parent 968454f commit 1168aa4

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/images/SkImageDecoder_libico.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ bool SkICOImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode)
160160
SkMemoryStream subStream(buf + offset, size, false);
161161
SkAutoTDelete<SkImageDecoder> otherDecoder(SkImageDecoder::Factory(&subStream));
162162
if (otherDecoder.get() != NULL) {
163+
// Disallow nesting ICO files within one another
164+
if (otherDecoder->getFormat() == SkImageDecoder::kICO_Format) {
165+
return false;
166+
}
163167
// Set fields on the other decoder to be the same as this one.
164168
this->copyFieldsToOther(otherDecoder.get());
165169
if(otherDecoder->decode(&subStream, bm, this->getDefaultPref(), mode)) {

0 commit comments

Comments
 (0)