From d258c36b2f964fe265a698dc2771fc350b8885a7 Mon Sep 17 00:00:00 2001 From: Akshata Kadam Date: Mon, 6 Nov 2023 07:56:35 +0000 Subject: [PATCH] content_decryption_fuzzer: Bug Fix Resolved timeout issue in content_decryption_fuzzer.cpp exec/sec: 10 Test: ./content_decryption_fuzzer clusterfuzz-testcase-minimized-content_decryption_fuzzer-6117614003748864 Bug: 3043856607 Change-Id: I5610e6bcae0bc88d5d7a31aa120adc30340b74f2 --- fuzzer/content_decryption_fuzzer.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/fuzzer/content_decryption_fuzzer.cpp b/fuzzer/content_decryption_fuzzer.cpp index 68b22b7b..c4db0e5c 100644 --- a/fuzzer/content_decryption_fuzzer.cpp +++ b/fuzzer/content_decryption_fuzzer.cpp @@ -31,6 +31,7 @@ static constexpr int32_t kMaxSetId = 100; static constexpr int32_t kMinSize = 1; static constexpr int32_t kMaxSize = 1024; static constexpr int32_t kMaxAppParamSize = 10; +static constexpr int32_t kMaxRuns = 100; const std::string kSecurityLevel[] = {"QUERY_VALUE_SECURITY_LEVEL_L1", "QUERY_VALUE_SECURITY_LEVEL_L2", @@ -180,7 +181,11 @@ private: void ContentDecryptionFuzzer::invokeDecryptorSessionAPIs() { CdmKeySetId keySetId = mFdp.ConsumeRandomLengthString(kMaxByte); - while (mFdp.remaining_bytes()) { + int32_t runs = kMaxRuns; + /* Limited the while loop to prevent a timeout caused by the + /* CryptoSession constructor, which took time to initialize + /* OEMCrypto in each iteration.*/ + while (mFdp.remaining_bytes() > 0 && --runs) { auto invokeDecryptionSessionAPI = mFdp.PickValueInArray>({ [&]() { mDecryptor->IsOpenSession(mSessionId); }, @@ -270,7 +275,11 @@ void ContentDecryptionFuzzer::invokeDecryptorSessionAPIs() { void ContentDecryptionFuzzer::invokeProvisionAPIs() { - while (mFdp.remaining_bytes()) { + int32_t runs = kMaxRuns; + /* Limited the while loop to prevent a timeout caused by the + /* CryptoSession constructor, which took time to initialize + /* OEMCrypto in each iteration.*/ + while (mFdp.remaining_bytes() > 0 && --runs) { auto invokeProvisionAPI = mFdp.PickValueInArray>({ [&]() {