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

Side by Side Diff: include/core/SkRegion.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, 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 /* 2 /*
3 * Copyright 2005 The Android Open Source Project 3 * Copyright 2005 The Android Open Source Project
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 9
10 #ifndef SkRegion_DEFINED 10 #ifndef SkRegion_DEFINED
11 #define SkRegion_DEFINED 11 #define SkRegion_DEFINED
12 12
13 #include "SkRect.h" 13 #include "SkRect.h"
14 14
15 class SkFlattenableReadBuffer;
15 class SkPath; 16 class SkPath;
16 class SkRgnBuilder; 17 class SkRgnBuilder;
17 18
18 namespace android { 19 namespace android {
19 class Region; 20 class Region;
20 } 21 }
21 22
22 #define SkRegion_gEmptyRunHeadPtr ((SkRegion::RunHead*)-1) 23 #define SkRegion_gEmptyRunHeadPtr ((SkRegion::RunHead*)-1)
23 #define SkRegion_gRectRunHeadPtr 0 24 #define SkRegion_gRectRunHeadPtr 0
24 25
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 Spanerator(const SkRegion&, int y, int left, int right); 352 Spanerator(const SkRegion&, int y, int left, int right);
352 bool next(int* left, int* right); 353 bool next(int* left, int* right);
353 354
354 private: 355 private:
355 const SkRegion::RunType* fRuns; 356 const SkRegion::RunType* fRuns;
356 int fLeft, fRight; 357 int fLeft, fRight;
357 bool fDone; 358 bool fDone;
358 }; 359 };
359 360
360 /** 361 /**
362 * Returns the number of bytes of the current object's flattened representa tion.
363 */
364 uint32_t sizeInMemory() const;
365 /**
366 * Returns the number of bytes to read.
367 */
368 static uint32_t SizeToRead(SkFlattenableReadBuffer& buffer);
369 /**
361 * Write the region to the buffer, and return the number of bytes written. 370 * Write the region to the buffer, and return the number of bytes written.
362 * If buffer is NULL, it still returns the number of bytes. 371 * If buffer is NULL, it still returns the number of bytes.
363 */ 372 */
364 uint32_t writeToMemory(void* buffer) const; 373 uint32_t writeToMemory(void* buffer) const;
365 374
366 /** 375 /**
367 * Initialized the region from the buffer, returning the number 376 * Initialized the region from the buffer, returning the number
368 * of bytes actually read. 377 * of bytes actually read.
369 */ 378 */
370 uint32_t readFromMemory(const void* buffer); 379 uint32_t readFromMemory(const void* buffer);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 static bool Oper(const SkRegion&, const SkRegion&, SkRegion::Op, SkRegion*); 446 static bool Oper(const SkRegion&, const SkRegion&, SkRegion::Op, SkRegion*);
438 447
439 friend struct RunHead; 448 friend struct RunHead;
440 friend class Iterator; 449 friend class Iterator;
441 friend class Spanerator; 450 friend class Spanerator;
442 friend class SkRgnBuilder; 451 friend class SkRgnBuilder;
443 friend class SkFlatRegion; 452 friend class SkFlatRegion;
444 }; 453 };
445 454
446 #endif 455 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698