blob: 2a773653e5374825ed27030f4a1a16d17d1e4210 [file] [log] [blame] [edit]
// Copyright 2021 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <base/big_endian.h>
#include <base/check.h>
#include <base/containers/span_writer.h>
#include <base/logging.h>
#include <fuzzer/FuzzedDataProvider.h>
#include "patchpanel/dns/dns_query.h"
#include "patchpanel/dns/io_buffer.h"
namespace patchpanel {
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
// Turn off logging.
logging::SetMinLogLevel(logging::LOGGING_FATAL);
FuzzedDataProvider provider(data, size);
auto buf = base::MakeRefCounted<IOBufferWithSize>(size);
size_t buf_size = static_cast<size_t>(buf->size());
base::SpanWriter<uint8_t> writer(
base::as_writable_bytes(base::make_span(buf->data(), buf_size)));
writer.Write(base::span(data, size));
DnsQuery query(buf);
query.Parse(buf_size);
return 0;
}
} // namespace patchpanel