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

Side by Side Diff: include/core/SkPath.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: Adding validation before memory allocation in SkRegion::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
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 SkPath_DEFINED 10 #ifndef SkPath_DEFINED
(...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 /** 892 /**
893 * Returns true if the point { x, y } is contained by the path, taking into 893 * Returns true if the point { x, y } is contained by the path, taking into
894 * account the FillType. 894 * account the FillType.
895 */ 895 */
896 bool contains(SkScalar x, SkScalar y) const; 896 bool contains(SkScalar x, SkScalar y) const;
897 897
898 void dump(bool forceClose, const char title[] = NULL) const; 898 void dump(bool forceClose, const char title[] = NULL) const;
899 void dump() const; 899 void dump() const;
900 900
901 /** 901 /**
902 * Write the region to the buffer, and return the number of bytes written. 902 * Write the path to the buffer, and return the number of bytes written.
903 * If buffer is NULL, it still returns the number of bytes. 903 * If buffer is NULL, it still returns the number of bytes.
904 */ 904 */
905 uint32_t writeToMemory(void* buffer) const; 905 size_t writeToMemory(void* buffer) const;
906
907 /** 906 /**
908 * Initialized the region from the buffer, returning the number 907 * Initializes the path from the buffer
909 * of bytes actually read. 908 *
909 * @param buffer Memory to read from
910 * @param length Amount of memory available in the buffer
911 * @return number of bytes read (must be a multiple of 4) or
912 * 0 if there was not enough memory available
910 */ 913 */
911 uint32_t readFromMemory(const void* buffer); 914 size_t readFromMemory(const void* buffer, size_t length);
912 915
913 /** Returns a non-zero, globally unique value corresponding to the set of ve rbs 916 /** Returns a non-zero, globally unique value corresponding to the set of ve rbs
914 and points in the path (but not the fill type [except on Android skbug.c om/1762]). 917 and points in the path (but not the fill type [except on Android skbug.c om/1762]).
915 Each time the path is modified, a different generation ID will be return ed. 918 Each time the path is modified, a different generation ID will be return ed.
916 */ 919 */
917 uint32_t getGenerationID() const; 920 uint32_t getGenerationID() const;
918 921
919 #ifdef SK_BUILD_FOR_ANDROID 922 #ifdef SK_BUILD_FOR_ANDROID
920 static const int kPathRefGenIDBitCnt = 30; // leave room for the fill type ( skbug.com/1762) 923 static const int kPathRefGenIDBitCnt = 30; // leave room for the fill type ( skbug.com/1762)
921 const SkPath* getSourcePath() const; 924 const SkPath* getSourcePath() const;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
1013 #ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TO O 1016 #ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TO O
1014 friend class SkPathRef; // just for SerializationOffsets 1017 friend class SkPathRef; // just for SerializationOffsets
1015 #endif 1018 #endif
1016 friend class SkAutoPathBoundsUpdate; 1019 friend class SkAutoPathBoundsUpdate;
1017 friend class SkAutoDisableOvalCheck; 1020 friend class SkAutoDisableOvalCheck;
1018 friend class SkAutoDisableDirectionCheck; 1021 friend class SkAutoDisableDirectionCheck;
1019 friend class SkBench_AddPathTest; // perf test pathTo/reversePathTo 1022 friend class SkBench_AddPathTest; // perf test pathTo/reversePathTo
1020 }; 1023 };
1021 1024
1022 #endif 1025 #endif
OLDNEW
« no previous file with comments | « include/core/SkMatrix.h ('k') | include/core/SkRRect.h » ('j') | tests/SerializationTest.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698