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>({ [&]() {