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

Unified Diff: chrome/common/partial_circular_buffer_unittest.cc

Issue 1061053002: Fix PartialCircularBuffer OOB memcpy(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 5 years, 8 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
« no previous file with comments | « chrome/common/partial_circular_buffer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/partial_circular_buffer_unittest.cc
diff --git a/chrome/common/partial_circular_buffer_unittest.cc b/chrome/common/partial_circular_buffer_unittest.cc
index 85153fac8d1e21f3cf1ca041fa9ea86dc8b75a59..701aefab374aa3b24c8ec265e4ee03559af870ba 100644
--- a/chrome/common/partial_circular_buffer_unittest.cc
+++ b/chrome/common/partial_circular_buffer_unittest.cc
@@ -189,3 +189,24 @@ TEST_F(PartialCircularBufferTest, WrapOnceThenOverwriteWithNoWrap) {
EXPECT_EQ(0u, pcb_read_->Read(output_data, sizeof(output_data)));
}
+
+TEST_F(PartialCircularBufferTest, WrapTwiceWithSingleWrite) {
+ const size_t kInputSize = sizeof(kInputData);
+ const size_t kLargeSize = kInputSize * 7;
+ uint8 large_input[kLargeSize] = {0};
+ for (size_t offset = 0; offset < kLargeSize; offset += kInputSize)
+ memcpy(large_input + offset, kInputData, kInputSize);
+
+ InitWriteBuffer(false);
+ pcb_write_->Write(large_input, kLargeSize);
+ InitReadBuffer();
+
+ uint8 output_data[sizeof(kOutputRefDataWrap)] = {0};
+ EXPECT_EQ(sizeof(output_data),
+ pcb_read_->Read(output_data, sizeof(output_data)));
+
+ EXPECT_EQ(0, memcmp(kOutputRefDataWrap, output_data, sizeof(output_data)));
+
+ EXPECT_EQ(0u, pcb_read_->Read(output_data, sizeof(output_data)));
+}
+
« no previous file with comments | « chrome/common/partial_circular_buffer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698