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

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

Issue 904833003: Fixed array read error (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 10 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 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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 } 168 }
169 if (!fError) { 169 if (!fError) {
170 (void)this->skip(size); 170 (void)this->skip(size);
171 } 171 }
172 } 172 }
173 173
174 bool SkValidatingReadBuffer::readArray(void* value, size_t size, size_t elementS ize) { 174 bool SkValidatingReadBuffer::readArray(void* value, size_t size, size_t elementS ize) {
175 const uint32_t count = this->getArrayCount(); 175 const uint32_t count = this->getArrayCount();
176 this->validate(size == count); 176 this->validate(size == count);
177 (void)this->skip(sizeof(uint32_t)); // Skip array count 177 (void)this->skip(sizeof(uint32_t)); // Skip array count
178 const uint64_t byteLength64 = sk_64_mul(count, elementSize);
178 const size_t byteLength = count * elementSize; 179 const size_t byteLength = count * elementSize;
180 this->validate(byteLength == byteLength64);
179 const void* ptr = this->skip(SkAlign4(byteLength)); 181 const void* ptr = this->skip(SkAlign4(byteLength));
180 if (!fError) { 182 if (!fError) {
181 memcpy(value, ptr, byteLength); 183 memcpy(value, ptr, byteLength);
182 return true; 184 return true;
183 } 185 }
184 return false; 186 return false;
185 } 187 }
186 188
187 bool SkValidatingReadBuffer::readByteArray(void* value, size_t size) { 189 bool SkValidatingReadBuffer::readByteArray(void* value, size_t size) {
188 return readArray(static_cast<unsigned char*>(value), size, sizeof(unsigned c har)); 190 return readArray(static_cast<unsigned char*>(value), size, sizeof(unsigned c har));
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 265
264 void SkValidatingReadBuffer::skipFlattenable() { 266 void SkValidatingReadBuffer::skipFlattenable() {
265 SkString name; 267 SkString name;
266 this->readString(&name); 268 this->readString(&name);
267 if (fError) { 269 if (fError) {
268 return; 270 return;
269 } 271 }
270 uint32_t sizeRecorded = this->readUInt(); 272 uint32_t sizeRecorded = this->readUInt();
271 this->skip(sizeRecorded); 273 this->skip(sizeRecorded);
272 } 274 }
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