blob: 95588789f09894c56250d2c6a2399771a1cc8210 [file] [log] [blame]
// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <fuzzer/FuzzedDataProvider.h>
#include <cstdint>
#include <string>
#include "base/containers/span.h"
#include "third_party/blink/public/common/privacy_budget/identifiable_token_builder.h"
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* fuzz_data,
size_t fuzz_data_size) {
FuzzedDataProvider fdp(fuzz_data, fuzz_data_size);
auto partition_count = fdp.ConsumeIntegralInRange<size_t>(0, fuzz_data_size);
blink::IdentifiableTokenBuilder token_builder;
for (size_t i = 0; i < partition_count; ++i) {
auto partition = fdp.ConsumeRandomLengthString(fuzz_data_size);
token_builder.AddBytes(base::as_bytes(base::make_span(partition)));
}
auto remainder = fdp.ConsumeRemainingBytes<uint8_t>();
token_builder.AddBytes(base::as_bytes(base::make_span(remainder)));
return 0;
}