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

Unified Diff: include/core/SkRRect.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 side-by-side diff with in-line comments
Download patch
Index: include/core/SkRRect.h
diff --git a/include/core/SkRRect.h b/include/core/SkRRect.h
index 402e6c6c4b276ef0ad92850495b08bd2fcccec5b..3c6386f1c68f3692da266fa1b1a1e6f31c9bc377 100644
--- a/include/core/SkRRect.h
+++ b/include/core/SkRRect.h
@@ -244,14 +244,20 @@ public:
* write kSizeInMemory bytes, and that value is guaranteed to always be
* a multiple of 4. Return kSizeInMemory.
*/
- uint32_t writeToMemory(void* buffer) const;
+ size_t writeToMemory(void* buffer) const;
/**
- * Read the rrect from the specified buffer. This is guaranteed to always
- * read kSizeInMemory bytes, and that value is guaranteed to always be
- * a multiple of 4. Return kSizeInMemory.
+ * Reads the rrect from the specified buffer
+ *
+ * If the specified buffer is large enough, this will read kSizeInMemory bytes,
+ * and that value is guaranteed to always be a multiple of 4.
+ *
+ * @param buffer Memory to read from
+ * @param length Amount of memory available in the buffer
+ * @return number of bytes read (must be a multiple of 4) or
+ * 0 if there was not enough memory available
*/
- uint32_t readFromMemory(const void* buffer);
+ size_t readFromMemory(const void* buffer, size_t length);
private:
SkRect fRect;
« no previous file with comments | « include/core/SkPath.h ('k') | include/core/SkReader32.h » ('j') | tests/SerializationTest.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698