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

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

Issue 23548034: Follow up to serialization validation code (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Merged in changes from 23021015 Created 7 years, 2 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 | Annotate | Revision Log
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 26 matching lines...) Expand all
37 } 37 }
38 return addr; 38 return addr;
39 } 39 }
40 40
41 // All the methods in this file funnel down into either readInt(), readScalar() or skip(), 41 // All the methods in this file funnel down into either readInt(), readScalar() or skip(),
42 // followed by a memcpy. So we've got all our validation in readInt(), readScala r() and skip(); 42 // followed by a memcpy. So we've got all our validation in readInt(), readScala r() and skip();
43 // if they fail they'll return a zero value or skip nothing, respectively, and s et fError to 43 // if they fail they'll return a zero value or skip nothing, respectively, and s et fError to
44 // true, which the caller should check to see if an error occurred during the re ad operation. 44 // true, which the caller should check to see if an error occurred during the re ad operation.
45 45
46 bool SkValidatingReadBuffer::readBool() { 46 bool SkValidatingReadBuffer::readBool() {
47 return this->readInt() != 0; 47 uint32_t value = this->readInt();
Stephen White 2013/10/23 18:09:35 Not new to this patch, but some flavours of writeB
sugoi1 2013/10/23 18:17:08 Yeah, I had to check that noone was doing any kind
48 // Boolean value should be either 0 or 1
49 if (value & 0xFFFFFFFE) {
reed1 2013/10/23 17:58:42 this is correct, but possibly hard for a reviewer
sugoi1 2013/10/23 18:07:43 Done.
50 fError = true;
51 }
52 return value != 0;
48 } 53 }
49 54
50 SkColor SkValidatingReadBuffer::readColor() { 55 SkColor SkValidatingReadBuffer::readColor() {
51 return this->readInt(); 56 return this->readInt();
52 } 57 }
53 58
54 SkFixed SkValidatingReadBuffer::readFixed() { 59 SkFixed SkValidatingReadBuffer::readFixed() {
55 return this->readInt(); 60 return this->readInt();
56 } 61 }
57 62
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 delete obj; 255 delete obj;
251 obj = NULL; 256 obj = NULL;
252 } 257 }
253 } else { 258 } else {
254 // we must skip the remaining data 259 // we must skip the remaining data
255 this->skip(sizeRecorded); 260 this->skip(sizeRecorded);
256 SkASSERT(false); 261 SkASSERT(false);
257 } 262 }
258 return obj; 263 return obj;
259 } 264 }
OLDNEW
« no previous file with comments | « no previous file | src/effects/SkMatrixConvolutionImageFilter.cpp » ('j') | src/effects/SkMatrixConvolutionImageFilter.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698