• 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 #ifdef UNSAFE_BUFFERS_BUILD
6 // TODO(crbug.com/40284755): Remove this and spanify to fix the errors.
7 #pragma allow_unsafe_buffers
8 #endif
9 
10 #include <string>
11 
12 #include "net/http/transport_security_state.h"
13 
14 namespace net {
15 
16 class TransportSecurityStateStaticFuzzer {
17  public:
FuzzStaticDomainState(TransportSecurityState * state,const std::string & input)18   bool FuzzStaticDomainState(TransportSecurityState* state,
19                              const std::string& input) {
20     state->enable_static_pins_ = true;
21     TransportSecurityState::STSState sts_result;
22     TransportSecurityState::PKPState pkp_result;
23     return state->GetStaticSTSState(input, &sts_result) ||
24            state->GetStaticPKPState(input, &pkp_result);
25   }
26 };
27 
28 }  // namespace net
29 
LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)30 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
31   std::string input(reinterpret_cast<const char*>(data), size);
32 
33   net::TransportSecurityStateStaticFuzzer helper;
34   net::TransportSecurityState state;
35 
36   helper.FuzzStaticDomainState(&state, input);
37 
38   return 0;
39 }
40