• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "net/cert/pki/verify_name_match.h"
6 
7 #include <stddef.h>
8 #include <stdint.h>
9 
10 #include <fuzzer/FuzzedDataProvider.h>
11 
12 #include <vector>
13 
14 #include "net/der/input.h"
15 
16 // Entry point for LibFuzzer.
LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)17 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
18   FuzzedDataProvider fuzzed_data(data, size);
19 
20   // Intentionally using uint16_t here to avoid empty |second_part|.
21   size_t first_part_size = fuzzed_data.ConsumeIntegral<uint16_t>();
22   std::vector<uint8_t> first_part =
23       fuzzed_data.ConsumeBytes<uint8_t>(first_part_size);
24   std::vector<uint8_t> second_part =
25       fuzzed_data.ConsumeRemainingBytes<uint8_t>();
26 
27   net::der::Input in1(first_part.data(), first_part.size());
28   net::der::Input in2(second_part.data(), second_part.size());
29   bool match = net::VerifyNameMatch(in1, in2);
30   bool reverse_order_match = net::VerifyNameMatch(in2, in1);
31   // Result should be the same regardless of argument order.
32   CHECK_EQ(match, reverse_order_match);
33   return 0;
34 }
35