Clean up fuzz helper classes
- Remove OEMCrypto state changes hidden in constructors and destructors. - Use composition instead of inheritance to structure classes. - Avoid calling non-trivial destructors for objects with static lifetime. Merged from https://widevine-internal-review.googlesource.com/168497 Merged from https://widevine-internal-review.googlesource.com/171170 Merged from https://widevine-internal-review.googlesource.com/171171 Merged from https://widevine-internal-review.googlesource.com/171870 Change-Id: I20476a7b1132d11f011b8650ec01e3c2dc3fc0e8
This commit is contained in:
@@ -2,27 +2,26 @@
|
||||
// source code may only be used and distributed under the Widevine
|
||||
// License Agreement.
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "oemcrypto_fuzz_helper.h"
|
||||
#include "oemcrypto_fuzz_structs.h"
|
||||
|
||||
namespace wvoec {
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
// Redirect printf and log statements from oemcrypto functions to a file to
|
||||
// reduce noise
|
||||
RedirectStdoutToFile();
|
||||
wvoec::RedirectStdoutToFile();
|
||||
|
||||
// If input size is less than fuzz data structure size, reject the input.
|
||||
if (size < sizeof(OEMCrypto_Request_Fuzz)) {
|
||||
if (size < sizeof(wvoec::OEMCrypto_Request_Fuzz)) {
|
||||
return 0;
|
||||
}
|
||||
// Input for provisioning request API will be modified by OEMCrypto, hence it
|
||||
// cannot be a const. Fuzzer complains if const identifier is removed of data,
|
||||
// hence copying data into a non const pointer.
|
||||
uint8_t* input = new uint8_t[size];
|
||||
memcpy(input, data, size);
|
||||
OEMCryptoProvisioningAPIFuzz provisioning_api_fuzz;
|
||||
provisioning_api_fuzz.provisioning_messages().InjectFuzzedRequestData(input,
|
||||
size);
|
||||
delete[] input;
|
||||
std::vector<uint8_t> input(data, data + size);
|
||||
wvoec::OEMCryptoProvisioningAPIFuzz provisioning_api_fuzz;
|
||||
provisioning_api_fuzz.Intialize();
|
||||
provisioning_api_fuzz.provisioning_messages().InjectFuzzedRequestData(
|
||||
input.data(), input.size());
|
||||
provisioning_api_fuzz.Terminate();
|
||||
return 0;
|
||||
}
|
||||
} // namespace wvoec
|
||||
Reference in New Issue
Block a user