blob: a5c80ebcd8361987982904e50bb0348d82cee658 [file] [log] [blame]
Lutz Justen70496c12019-07-24 11:11:55 +02001// Copyright 2019 The Chromium OS Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Felipe Andradea0cbde72020-04-01 15:40:10 +02005#include "kerberos/config_parser.h"
Manoj Guptafc4482c2019-09-20 13:43:02 -07006#include "kerberos/krb5_interface_impl.h"
Lutz Justen70496c12019-07-24 11:11:55 +02007
8#include <stddef.h>
9#include <stdint.h>
Manoj Guptafc4482c2019-09-20 13:43:02 -070010#include <fuzzer/FuzzedDataProvider.h>
Lutz Justen70496c12019-07-24 11:11:55 +020011
12#include "base/logging.h"
Lutz Justen70496c12019-07-24 11:11:55 +020013
14struct Environment {
hschame6711302020-11-20 17:08:14 +090015 Environment() { logging::SetMinLogLevel(logging::LOGGING_FATAL); }
Lutz Justen70496c12019-07-24 11:11:55 +020016};
17
18extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
19 static Environment env;
Maksim Ivanova1f19452021-03-12 20:35:07 +010020
21 // Bail out on huge inputs, in order to avoid timeouts.
22 constexpr int kMaxInputSize = 50000;
23 if (size > kMaxInputSize)
24 return 0;
25
Lutz Justen70496c12019-07-24 11:11:55 +020026 const std::string krb5conf(reinterpret_cast<const char*>(data), size);
27
Felipe Andradea0cbde72020-04-01 15:40:10 +020028 // Note: Krb5InterfaceImpl owns and calls a ConfigParser, but it also runs
Lutz Justen70496c12019-07-24 11:11:55 +020029 // the MIT krb5 parsing code, so we use that.
30 kerberos::Krb5InterfaceImpl krb5;
31
32 kerberos::ConfigErrorInfo error_info;
33 krb5.ValidateConfig(krb5conf, &error_info);
34
35 return 0;
36}