Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(844)

Side by Side Diff: src/images/SkImageDecoder_libico.cpp

Issue 511453002: Prevent malformed ICO files from recursively decoding (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkColorPriv.h" 8 #include "SkColorPriv.h"
9 #include "SkImageDecoder.h" 9 #include "SkImageDecoder.h"
10 #include "SkStream.h" 10 #include "SkStream.h"
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 // promote the sum to 64-bits to avoid overflow 157 // promote the sum to 64-bits to avoid overflow
158 if (((uint64_t)offset + size) > length) { 158 if (((uint64_t)offset + size) > length) {
159 return false; 159 return false;
160 } 160 }
161 161
162 // Check to see if this is a PNG image inside the ICO 162 // Check to see if this is a PNG image inside the ICO
163 { 163 {
164 SkMemoryStream subStream(buf + offset, size, false); 164 SkMemoryStream subStream(buf + offset, size, false);
165 SkAutoTDelete<SkImageDecoder> otherDecoder(SkImageDecoder::Factory(&subS tream)); 165 SkAutoTDelete<SkImageDecoder> otherDecoder(SkImageDecoder::Factory(&subS tream));
166 if (otherDecoder.get() != NULL) { 166 if (otherDecoder.get() != NULL) {
167 // Disallow nesting ICO files within one another
reed1 2014/08/26 17:53:34 Can we add a test case/data for this?
168 if (otherDecoder->getFormat() == SkImageDecoder::kICO_Format) {
scroggo 2014/10/14 22:58:23 We could be more aggressive here; I think the only
169 return false;
170 }
167 // Set fields on the other decoder to be the same as this one. 171 // Set fields on the other decoder to be the same as this one.
168 this->copyFieldsToOther(otherDecoder.get()); 172 this->copyFieldsToOther(otherDecoder.get());
169 if(otherDecoder->decode(&subStream, bm, this->getDefaultPref(), mode )) { 173 if(otherDecoder->decode(&subStream, bm, this->getDefaultPref(), mode )) {
170 return true; 174 return true;
171 } 175 }
172 } 176 }
173 } 177 }
174 178
175 //int infoSize = read4Bytes(buf, offset); //40 179 //int infoSize = read4Bytes(buf, offset); //40
176 //int width = read4Bytes(buf, offset+4); //should == w 180 //int width = read4Bytes(buf, offset+4); //should == w
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 static SkImageDecoder_DecodeReg gReg(sk_libico_dfactory); 418 static SkImageDecoder_DecodeReg gReg(sk_libico_dfactory);
415 419
416 static SkImageDecoder::Format get_format_ico(SkStreamRewindable* stream) { 420 static SkImageDecoder::Format get_format_ico(SkStreamRewindable* stream) {
417 if (is_ico(stream)) { 421 if (is_ico(stream)) {
418 return SkImageDecoder::kICO_Format; 422 return SkImageDecoder::kICO_Format;
419 } 423 }
420 return SkImageDecoder::kUnknown_Format; 424 return SkImageDecoder::kUnknown_Format;
421 } 425 }
422 426
423 static SkImageDecoder_FormatReg gFormatReg(get_format_ico); 427 static SkImageDecoder_FormatReg gFormatReg(get_format_ico);
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698