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

Side by Side 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: Revert back to Patch Set 4 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
« include/core/SkReader32.h ('K') | « tests/MatrixTest.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "Test.h" 8 #include "Test.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkPaint.h" 10 #include "SkPaint.h"
(...skipping 1745 matching lines...) Expand 10 before | Expand all | Expand 10 after
1756 write_and_read_back(reporter, p); 1756 write_and_read_back(reporter, p);
1757 1757
1758 // create a buffer that should be much larger than the path so we don't 1758 // create a buffer that should be much larger than the path so we don't
1759 // kill our stack if writer goes too far. 1759 // kill our stack if writer goes too far.
1760 char buffer[1024]; 1760 char buffer[1024];
1761 uint32_t size1 = p.writeToMemory(NULL); 1761 uint32_t size1 = p.writeToMemory(NULL);
1762 uint32_t size2 = p.writeToMemory(buffer); 1762 uint32_t size2 = p.writeToMemory(buffer);
1763 REPORTER_ASSERT(reporter, size1 == size2); 1763 REPORTER_ASSERT(reporter, size1 == size2);
1764 1764
1765 SkPath p2; 1765 SkPath p2;
1766 uint32_t size3 = p2.readFromMemory(buffer); 1766 uint32_t size3 = p2.readFromMemory(buffer, 1024);
1767 REPORTER_ASSERT(reporter, size1 == size3); 1767 REPORTER_ASSERT(reporter, size1 == size3);
1768 REPORTER_ASSERT(reporter, p == p2); 1768 REPORTER_ASSERT(reporter, p == p2);
1769 1769
1770 char buffer2[1024]; 1770 char buffer2[1024];
1771 size3 = p2.writeToMemory(buffer2); 1771 size3 = p2.writeToMemory(buffer2);
1772 REPORTER_ASSERT(reporter, size1 == size3); 1772 REPORTER_ASSERT(reporter, size1 == size3);
1773 REPORTER_ASSERT(reporter, memcmp(buffer, buffer2, size1) == 0); 1773 REPORTER_ASSERT(reporter, memcmp(buffer, buffer2, size1) == 0);
1774 1774
1775 // test persistence of the oval flag & convexity 1775 // test persistence of the oval flag & convexity
1776 { 1776 {
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after
2619 test_crbug_170666(); 2619 test_crbug_170666();
2620 test_bad_cubic_crbug229478(); 2620 test_bad_cubic_crbug229478();
2621 test_bad_cubic_crbug234190(); 2621 test_bad_cubic_crbug234190();
2622 test_android_specific_behavior(reporter); 2622 test_android_specific_behavior(reporter);
2623 test_path_close_issue1474(reporter); 2623 test_path_close_issue1474(reporter);
2624 test_path_to_region(reporter); 2624 test_path_to_region(reporter);
2625 } 2625 }
2626 2626
2627 #include "TestClassDef.h" 2627 #include "TestClassDef.h"
2628 DEFINE_TESTCLASS("Path", PathTestClass, TestPath) 2628 DEFINE_TESTCLASS("Path", PathTestClass, TestPath)
OLDNEW
« include/core/SkReader32.h ('K') | « tests/MatrixTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698