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

Side by Side Diff: include/core/SkPathRef.h

Issue 41253002: Checking structure sizes before reading them from memory to avoid overflowing the buffer's stream. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 1 month 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 /* 2 /*
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #ifndef SkPathRef_DEFINED 9 #ifndef SkPathRef_DEFINED
10 #define SkPathRef_DEFINED 10 #define SkPathRef_DEFINED
11 11
12 #include "SkMatrix.h" 12 #include "SkMatrix.h"
13 #include "SkPoint.h" 13 #include "SkPoint.h"
14 #include "SkRect.h" 14 #include "SkRect.h"
15 #include "SkRefCnt.h" 15 #include "SkRefCnt.h"
16 #include "SkTDArray.h" 16 #include "SkTDArray.h"
17 #include <stddef.h> // ptrdiff_t 17 #include <stddef.h> // ptrdiff_t
18 18
19 class SkFlattenableReadBuffer;
19 class SkRBuffer; 20 class SkRBuffer;
20 class SkWBuffer; 21 class SkWBuffer;
21 22
22 /** 23 /**
23 * Holds the path verbs and points. It is versioned by a generation ID. None of its public methods 24 * Holds the path verbs and points. It is versioned by a generation ID. None of its public methods
24 * modify the contents. To modify or append to the verbs/points wrap the SkPathR ef in an 25 * modify the contents. To modify or append to the verbs/points wrap the SkPathR ef in an
25 * SkPathRef::Editor object. Installing the editor resets the generation ID. It also performs 26 * SkPathRef::Editor object. Installing the editor resets the generation ID. It also performs
26 * copy-on-write if the SkPathRef is shared by multipls SkPaths. The caller pass es the Editor's 27 * copy-on-write if the SkPathRef is shared by multipls SkPaths. The caller pass es the Editor's
27 * constructor a SkAutoTUnref, which may be updated to point to a new SkPathRef after the editor's 28 * constructor a SkAutoTUnref, which may be updated to point to a new SkPathRef after the editor's
28 * constructor returns. 29 * constructor returns.
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 const SkPathRef& src, 152 const SkPathRef& src,
152 const SkMatrix& matrix); 153 const SkMatrix& matrix);
153 154
154 static SkPathRef* CreateFromBuffer(SkRBuffer* buffer 155 static SkPathRef* CreateFromBuffer(SkRBuffer* buffer
155 #ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TO O 156 #ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TO O
156 , bool newFormat, int32_t oldPacked 157 , bool newFormat, int32_t oldPacked
157 #endif 158 #endif
158 ); 159 );
159 160
160 /** 161 /**
162 * Returns the number of bytes that will be read in CreateFromBuffer()
163 */
164 static uint32_t SizeToRead(SkFlattenableReadBuffer& buffer
165 #ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TO O
166 , bool newFormat
167 #endif
168 );
169
170
171 /**
161 * Rollsback a path ref to zero verbs and points with the assumption that th e path ref will be 172 * Rollsback a path ref to zero verbs and points with the assumption that th e path ref will be
162 * repopulated with approximately the same number of verbs and points. A new path ref is created 173 * repopulated with approximately the same number of verbs and points. A new path ref is created
163 * only if necessary. 174 * only if necessary.
164 */ 175 */
165 static void Rewind(SkAutoTUnref<SkPathRef>* pathRef); 176 static void Rewind(SkAutoTUnref<SkPathRef>* pathRef);
166 177
167 virtual ~SkPathRef() { 178 virtual ~SkPathRef() {
168 SkDEBUGCODE(this->validate();) 179 SkDEBUGCODE(this->validate();)
169 sk_free(fPoints); 180 sk_free(fPoints);
170 181
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 enum { 424 enum {
414 kEmptyGenID = 1, // GenID reserved for path ref with zero points and zer o verbs. 425 kEmptyGenID = 1, // GenID reserved for path ref with zero points and zer o verbs.
415 }; 426 };
416 mutable int32_t fGenerationID; 427 mutable int32_t fGenerationID;
417 SkDEBUGCODE(int32_t fEditorsAttached;) // assert that only one editor in use at any time. 428 SkDEBUGCODE(int32_t fEditorsAttached;) // assert that only one editor in use at any time.
418 429
419 typedef SkRefCnt INHERITED; 430 typedef SkRefCnt INHERITED;
420 }; 431 };
421 432
422 #endif 433 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698