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

Unified Diff: src/core/SkPath.cpp

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 length info to read operations 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 side-by-side diff with in-line comments
Download patch
Index: src/core/SkPath.cpp
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index 9df62850fd2eb5bc9cf442dc4675b7091cded8c1..11caac4c2d8b398723fa686efa38667838406cae 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -2113,8 +2113,8 @@ uint32_t SkPath::writeToMemory(void* storage) const {
return SkToU32(buffer.pos());
}
-uint32_t SkPath::readFromMemory(const void* storage) {
- SkRBuffer buffer(storage);
+uint32_t SkPath::readFromMemory(const void* storage, uint32_t length) {
+ SkRBuffer buffer(storage, length);
uint32_t packed = buffer.readS32();
fIsOval = (packed >> kIsOval_SerializationShift) & 1;
@@ -2128,9 +2128,9 @@ uint32_t SkPath::readFromMemory(const void* storage) {
fPathRef.reset(SkPathRef::CreateFromBuffer(&buffer
#ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TOO
- , newFormat, packed)
+ , newFormat, packed
#endif
- );
+ ));
buffer.skipToAlign4();
« include/core/SkMatrix.h ('K') | « src/core/SkMatrix.cpp ('k') | src/core/SkRegion.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698