chromium/net/spdy/fuzzing/hpack_fuzz_util.cc

// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40284755): Remove this and spanify to fix the errors.
#pragma allow_unsafe_buffers
#endif

#include "net/spdy/fuzzing/hpack_fuzz_util.h"

#include <algorithm>
#include <cmath>
#include <memory>

#include "base/containers/span.h"
#include "base/numerics/byte_conversions.h"
#include "base/rand_util.h"
#include "net/third_party/quiche/src/quiche/common/http/http_header_block.h"
#include "net/third_party/quiche/src/quiche/http2/hpack/hpack_constants.h"

namespace spdy {

namespace {

HttpHeaderBlock;

// Sampled exponential distribution parameters:
// Number of headers in each header set.
const size_t kHeaderCountMean =;
const size_t kHeaderCountMax =;
// Selected index within list of headers.
const size_t kHeaderIndexMean =;
const size_t kHeaderIndexMax =;
// Approximate distribution of header name lengths.
const size_t kNameLengthMean =;
const size_t kNameLengthMax =;
// Approximate distribution of header value lengths.
const size_t kValueLengthMean =;
const size_t kValueLengthMax =;

}  //  namespace

RandBytesAsString;
map;

HpackFuzzUtil::GeneratorContext::GeneratorContext() = default;
HpackFuzzUtil::GeneratorContext::~GeneratorContext() = default;

HpackFuzzUtil::Input::Input() = default;
HpackFuzzUtil::Input::~Input() = default;

HpackFuzzUtil::FuzzerContext::FuzzerContext() = default;
HpackFuzzUtil::FuzzerContext::~FuzzerContext() = default;

// static
void HpackFuzzUtil::InitializeGeneratorContext(GeneratorContext* context) {}

// static
HttpHeaderBlock HpackFuzzUtil::NextGeneratedHeaderSet(
    GeneratorContext* context) {}

// static
size_t HpackFuzzUtil::SampleExponential(size_t mean, size_t sanity_bound) {}

// static
bool HpackFuzzUtil::NextHeaderBlock(Input* input, std::string_view* out) {}

// static
std::string HpackFuzzUtil::HeaderBlockPrefix(size_t block_size) {}

// static
void HpackFuzzUtil::InitializeFuzzerContext(FuzzerContext* context) {}

// static
bool HpackFuzzUtil::RunHeaderBlockThroughFuzzerStages(
    FuzzerContext* context,
    std::string_view input_block) {}

// static
void HpackFuzzUtil::FlipBits(uint8_t* buffer,
                             size_t buffer_length,
                             size_t flip_per_thousand) {}

}  // namespace spdy