From ea43147a08cd9f1058493e34b36e4872650d354c Mon Sep 17 00:00:00 2001 From: Ian Benz Date: Fri, 12 May 2023 14:26:06 +0000 Subject: [PATCH] Add OEMCrypto_GetDeviceInformation fuzzer Merged from https://widevine-internal-review.googlesource.com/174936 Change-Id: I79bbb8506a13d3142a8b323a7c67d0155973a3f4 --- .../oemcrypto_get_device_information_fuzz.cc | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_get_device_information_fuzz.cc diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_get_device_information_fuzz.cc b/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_get_device_information_fuzz.cc new file mode 100644 index 00000000..191fe381 --- /dev/null +++ b/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_get_device_information_fuzz.cc @@ -0,0 +1,31 @@ +// Copyright 2023 Google LLC. All Rights Reserved. This file and proprietary +// source code may only be used and distributed under the Widevine +// License Agreement. + +#include + +#include "FuzzedDataProvider.h" +#include "OEMCryptoCENC.h" +#include "oemcrypto_fuzz_helper.h" + +extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv) { + wvoec::RedirectStdoutToFile(); + wvoec::SessionUtil session_util; + wvoec::InitializeFuzz(session_util); + return 0; +} + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { + FuzzedDataProvider fuzzed_data(data, size); + + // device_info and device_info_length parameters + size_t device_info_length_data = fuzzed_data.ConsumeIntegralInRange( + 0, wvoec::MAX_FUZZ_OUTPUT_LENGTH); + std::vector device_info(device_info_length_data); + size_t* const device_info_length = + fuzzed_data.ConsumeBool() ? &device_info_length_data : nullptr; + + OEMCrypto_GetDeviceInformation(device_info.data(), device_info_length); + + return 0; +}