| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/spdy/spdy_alt_svc_wire_format.h" | 5 #include "net/spdy/spdy_alt_svc_wire_format.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "testing/gmock/include/gmock/gmock.h" | 8 #include "testing/gmock/include/gmock/gmock.h" |
| 9 #include "testing/platform_test.h" | 9 #include "testing/platform_test.h" |
| 10 | 10 |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 } | 256 } |
| 257 } | 257 } |
| 258 | 258 |
| 259 // ParseHeaderFieldValue() should return false on a field values truncated | 259 // ParseHeaderFieldValue() should return false on a field values truncated |
| 260 // before closing quotation mark, without trying to access memory beyond the end | 260 // before closing quotation mark, without trying to access memory beyond the end |
| 261 // of the input. | 261 // of the input. |
| 262 TEST(SpdyAltSvcWireFormatTest, ParseTruncatedHeaderFieldValue) { | 262 TEST(SpdyAltSvcWireFormatTest, ParseTruncatedHeaderFieldValue) { |
| 263 SpdyAltSvcWireFormat::AlternativeServiceVector altsvc_vector; | 263 SpdyAltSvcWireFormat::AlternativeServiceVector altsvc_vector; |
| 264 const char* field_value_array[] = { | 264 const char* field_value_array[] = { |
| 265 "p=\":137\"", "p=\"foo:137\"", "p%25=\"foo\\\"bar\\\\baz:137\""}; | 265 "p=\":137\"", "p=\"foo:137\"", "p%25=\"foo\\\"bar\\\\baz:137\""}; |
| 266 for (std::string field_value : field_value_array) { | 266 for (const std::string& field_value : field_value_array) { |
| 267 for (size_t len = 1; len < field_value.size(); ++len) { | 267 for (size_t len = 1; len < field_value.size(); ++len) { |
| 268 EXPECT_FALSE(SpdyAltSvcWireFormat::ParseHeaderFieldValue( | 268 EXPECT_FALSE(SpdyAltSvcWireFormat::ParseHeaderFieldValue( |
| 269 field_value.substr(0, len), &altsvc_vector)) | 269 field_value.substr(0, len), &altsvc_vector)) |
| 270 << len; | 270 << len; |
| 271 } | 271 } |
| 272 } | 272 } |
| 273 } | 273 } |
| 274 | 274 |
| 275 // Tests of private methods. | 275 // Tests of private methods. |
| 276 | 276 |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 StringPiece input(invalid_input); | 481 StringPiece input(invalid_input); |
| 482 double probability; | 482 double probability; |
| 483 EXPECT_FALSE(test::SpdyAltSvcWireFormatPeer::ParseProbability( | 483 EXPECT_FALSE(test::SpdyAltSvcWireFormatPeer::ParseProbability( |
| 484 input.begin(), input.end(), &probability)); | 484 input.begin(), input.end(), &probability)); |
| 485 } | 485 } |
| 486 } | 486 } |
| 487 | 487 |
| 488 } // namespace | 488 } // namespace |
| 489 | 489 |
| 490 } // namespace net | 490 } // namespace net |
| OLD | NEW |