| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/cert/internal/verify_name_match.h" | 5 #include "net/cert/internal/verify_name_match.h" |
| 6 | 6 |
| 7 #include "net/base/fuzzed_data_provider.h" | 7 #include "base/fuzzed_data_provider.h" |
| 8 #include "net/der/input.h" | 8 #include "net/der/input.h" |
| 9 | 9 |
| 10 // Entry point for LibFuzzer. | 10 // Entry point for LibFuzzer. |
| 11 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { | 11 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { |
| 12 net::FuzzedDataProvider fuzzed_data(data, size); | 12 base::FuzzedDataProvider fuzzed_data(data, size); |
| 13 size_t first_part_size = fuzzed_data.ConsumeUint16(); | 13 size_t first_part_size = fuzzed_data.ConsumeUint16(); |
| 14 base::StringPiece first_part = fuzzed_data.ConsumeBytes(first_part_size); | 14 base::StringPiece first_part = fuzzed_data.ConsumeBytes(first_part_size); |
| 15 base::StringPiece second_part = fuzzed_data.ConsumeRemainingBytes(); | 15 base::StringPiece second_part = fuzzed_data.ConsumeRemainingBytes(); |
| 16 | 16 |
| 17 net::der::Input in1(first_part); | 17 net::der::Input in1(first_part); |
| 18 net::der::Input in2(second_part); | 18 net::der::Input in2(second_part); |
| 19 bool match = net::VerifyNameMatch(in1, in2); | 19 bool match = net::VerifyNameMatch(in1, in2); |
| 20 bool reverse_order_match = net::VerifyNameMatch(in2, in1); | 20 bool reverse_order_match = net::VerifyNameMatch(in2, in1); |
| 21 // Result should be the same regardless of argument order. | 21 // Result should be the same regardless of argument order. |
| 22 CHECK_EQ(match, reverse_order_match); | 22 CHECK_EQ(match, reverse_order_match); |
| 23 return 0; | 23 return 0; |
| 24 } | 24 } |
| OLD | NEW |