audio: Add checks to effects feature configs retrieval
The size of the feature config needs to be limited
by the Binder transaction size. This check is enforced
before calling into legacy C API.
Also, fixed invalid calculation of buffer size
in Effect::getSupportedConfigsImpl.
Bug: 240266798
Test: atest VtsHalAudioEffectV7_0TargetTest
Change-Id: I1a1f7931a07e28642967fa68d9a358429138db29
diff --git a/audio/effect/all-versions/default/Effect.h b/audio/effect/all-versions/default/Effect.h
index f0b65df..5d8dccc 100644
--- a/audio/effect/all-versions/default/Effect.h
+++ b/audio/effect/all-versions/default/Effect.h
@@ -184,6 +184,9 @@
using GetSupportedConfigsSuccessCallback =
std::function<void(uint32_t supportedConfigs, void* configsData)>;
+ // Sets the limit on the maximum size of vendor-provided data structures.
+ static constexpr size_t kMaxDataSize = 1 << 20;
+
static const char* sContextResultOfCommand;
static const char* sContextCallToCommand;
static const char* sContextCallFunction;