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

Unified Diff: net/der/input_unittest.cc

Issue 1160643002: Remove dangerous std::string constructor for der::Input (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove FromCString; use uint8_t array literals instead of string literals now Created 5 years, 7 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: net/der/input_unittest.cc
diff --git a/net/der/input_unittest.cc b/net/der/input_unittest.cc
index dc58d4b0d0399094584254b06c1c84713b057f70..7d7b720b41d2d51244a94b5c7bb3596b1336a0c3 100644
--- a/net/der/input_unittest.cc
+++ b/net/der/input_unittest.cc
@@ -17,8 +17,8 @@ TEST(InputTest, Equals) {
Input test2(kInput, arraysize(kInput));
EXPECT_TRUE(test.Equals(test2));
- std::string input_copy(reinterpret_cast<const char*>(kInput),
- arraysize(kInput));
+ uint8_t input_copy[arraysize(kInput)] = {0};
+ memcpy(input_copy, kInput, arraysize(kInput));
Input test_copy(input_copy);
EXPECT_TRUE(test.Equals(test_copy));
@@ -85,7 +85,9 @@ TEST(ByteReaderTest, ReadToMark) {
TEST(ByteReaderTest, CantReadToWrongMark) {
Input out;
Input in1(kInput, arraysize(kInput));
- Input in2("test");
+
+ const uint8_t in2_bytes[] = {'t', 'e', 's', 't'};
+ Input in2(in2_bytes);
ByteReader reader1(in1);
ByteReader reader2(in2);
ASSERT_TRUE(reader1.ReadBytes(2, &out));

Powered by Google App Engine
This is Rietveld 408576698