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

Side by Side Diff: include/core/SkMatrix.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: Removing SkMatrix's writeToMemory, readFromMemory 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
« no previous file with comments | « no previous file | include/core/SkPath.h » ('j') | include/core/SkReader32.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 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 SkMatrix_DEFINED 10 #ifndef SkMatrix_DEFINED
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 friend bool operator==(const SkMatrix& a, const SkMatrix& b) { 547 friend bool operator==(const SkMatrix& a, const SkMatrix& b) {
548 return a.cheapEqualTo(b); 548 return a.cheapEqualTo(b);
549 } 549 }
550 #else 550 #else
551 friend bool operator==(const SkMatrix& a, const SkMatrix& b); 551 friend bool operator==(const SkMatrix& a, const SkMatrix& b);
552 #endif 552 #endif
553 friend bool operator!=(const SkMatrix& a, const SkMatrix& b) { 553 friend bool operator!=(const SkMatrix& a, const SkMatrix& b) {
554 return !(a == b); 554 return !(a == b);
555 } 555 }
556 556
557 enum {
558 // writeTo/readFromMemory will never return a value larger than this
559 kMaxFlattenSize = 9 * sizeof(SkScalar) + sizeof(uint32_t)
560 };
561 // return the number of bytes written, whether or not buffer is null
562 uint32_t writeToMemory(void* buffer) const;
563 // return the number of bytes read
564 uint32_t readFromMemory(const void* buffer);
565
566 SkDEVCODE(void dump() const;) 557 SkDEVCODE(void dump() const;)
567 SkDEVCODE(void toString(SkString*) const;) 558 SkDEVCODE(void toString(SkString*) const;)
568 559
569 /** 560 /**
570 * Calculates the maximum stretching factor of the matrix. If the matrix has 561 * Calculates the maximum stretching factor of the matrix. If the matrix has
571 * perspective -1 is returned. 562 * perspective -1 is returned.
572 * 563 *
573 * @return maximum strecthing factor 564 * @return maximum strecthing factor
574 */ 565 */
575 SkScalar getMaxStretch() const; 566 SkScalar getMaxStretch() const;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 static void RotTrans_pts(const SkMatrix&, SkPoint dst[], const SkPoint[], 681 static void RotTrans_pts(const SkMatrix&, SkPoint dst[], const SkPoint[],
691 int count); 682 int count);
692 static void Persp_pts(const SkMatrix&, SkPoint dst[], const SkPoint[], int); 683 static void Persp_pts(const SkMatrix&, SkPoint dst[], const SkPoint[], int);
693 684
694 static const MapPtsProc gMapPtsProcs[]; 685 static const MapPtsProc gMapPtsProcs[];
695 686
696 friend class SkPerspIter; 687 friend class SkPerspIter;
697 }; 688 };
698 689
699 #endif 690 #endif
OLDNEW
« no previous file with comments | « no previous file | include/core/SkPath.h » ('j') | include/core/SkReader32.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698