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

Side by Side Diff: src/core/SkValidatingReadBuffer.cpp

Issue 116773002: Fixed more fuzzer issues (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Changed isAvailable for validateAvailable Created 7 years 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
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
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 "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkErrorInternals.h" 9 #include "SkErrorInternals.h"
10 #include "SkValidatingReadBuffer.h" 10 #include "SkValidatingReadBuffer.h"
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 } 221 }
222 bitmap->unflatten(*this); 222 bitmap->unflatten(*this);
223 this->validate((bitmap->width() == width) && (bitmap->height() == height)); 223 this->validate((bitmap->width() == width) && (bitmap->height() == height));
224 } 224 }
225 225
226 SkTypeface* SkValidatingReadBuffer::readTypeface() { 226 SkTypeface* SkValidatingReadBuffer::readTypeface() {
227 // TODO: Implement this (securely) when needed 227 // TODO: Implement this (securely) when needed
228 return NULL; 228 return NULL;
229 } 229 }
230 230
231 bool SkValidatingReadBuffer::validateAvailable(size_t size) {
232 return this->validate((size <= SK_MaxU32) && fReader.isAvailable(static_cast <uint32_t>(size)));
233 }
234
231 SkFlattenable* SkValidatingReadBuffer::readFlattenable(SkFlattenable::Type type) { 235 SkFlattenable* SkValidatingReadBuffer::readFlattenable(SkFlattenable::Type type) {
232 SkString name; 236 SkString name;
233 this->readString(&name); 237 this->readString(&name);
234 if (fError) { 238 if (fError) {
235 return NULL; 239 return NULL;
236 } 240 }
237 241
238 // Is this the type we wanted ? 242 // Is this the type we wanted ?
239 const char* cname = name.c_str(); 243 const char* cname = name.c_str();
240 SkFlattenable::Type baseType; 244 SkFlattenable::Type baseType;
(...skipping 21 matching lines...) Expand all
262 delete obj; 266 delete obj;
263 obj = NULL; 267 obj = NULL;
264 } 268 }
265 } else { 269 } else {
266 // we must skip the remaining data 270 // we must skip the remaining data
267 this->skip(sizeRecorded); 271 this->skip(sizeRecorded);
268 SkASSERT(false); 272 SkASSERT(false);
269 } 273 }
270 return obj; 274 return obj;
271 } 275 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698