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

Unified Diff: tests/PathTest.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 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: tests/PathTest.cpp
diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp
index d879ea6e33e4523e67e296c12fcacd9f6800c739..f6c2a7ae6e231681c32cc91a1256ecaf79fc59e9 100644
--- a/tests/PathTest.cpp
+++ b/tests/PathTest.cpp
@@ -1808,12 +1808,12 @@ static void test_flattening(skiatest::Reporter* reporter) {
// create a buffer that should be much larger than the path so we don't
// kill our stack if writer goes too far.
char buffer[1024];
- uint32_t size1 = p.writeToMemory(NULL);
- uint32_t size2 = p.writeToMemory(buffer);
+ size_t size1 = p.writeToMemory(NULL);
+ size_t size2 = p.writeToMemory(buffer);
REPORTER_ASSERT(reporter, size1 == size2);
SkPath p2;
- uint32_t size3 = p2.readFromMemory(buffer);
+ size_t size3 = p2.readFromMemory(buffer, 1024);
REPORTER_ASSERT(reporter, size1 == size3);
REPORTER_ASSERT(reporter, p == p2);
« no previous file with comments | « tests/MatrixTest.cpp ('k') | tests/SerializationTest.cpp » ('j') | tests/SerializationTest.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698