Add parameters validation on AAudio MMap server
Bug: 63384314
Test: adb shell /system/bin/write_sine -m -pl -n4 \
&& adb shell /system/bin/write_sine -pl -n4 \
&& adb shell /system/bin/write_sine_callback -m -pl -n4 \
&& adb shell /system/bin/write_sine_callback -pl -n4 \
&& adb shell /system/bin/CtsNativeMediaAAudioTestCases32
Change-Id: I462f956e8fc25eb583699af6389e0f299243eafb
diff --git a/media/libaaudio/src/binding/IAAudioService.cpp b/media/libaaudio/src/binding/IAAudioService.cpp
index 97fbaaa..b3c4934 100644
--- a/media/libaaudio/src/binding/IAAudioService.cpp
+++ b/media/libaaudio/src/binding/IAAudioService.cpp
@@ -264,13 +264,19 @@
case OPEN_STREAM: {
CHECK_INTERFACE(IAAudioService, data, reply);
request.readFromParcel(&data);
- //ALOGD("BnAAudioService::client openStream request dump --------------------");
- //request.dump();
- // Override the uid and pid from the client in case they are incorrect.
- request.setUserId(IPCThreadState::self()->getCallingUid());
- request.setProcessId(IPCThreadState::self()->getCallingPid());
- streamHandle = openStream(request, configuration);
- //ALOGD("BnAAudioService::onTransact OPEN_STREAM server handle = 0x%08X", streamHandle);
+ result = request.validate();
+ if (result != AAUDIO_OK) {
+ streamHandle = result;
+ } else {
+ //ALOGD("BnAAudioService::client openStream request dump --------------------");
+ //request.dump();
+ // Override the uid and pid from the client in case they are incorrect.
+ request.setUserId(IPCThreadState::self()->getCallingUid());
+ request.setProcessId(IPCThreadState::self()->getCallingPid());
+ streamHandle = openStream(request, configuration);
+ //ALOGD("BnAAudioService::onTransact OPEN_STREAM server handle = 0x%08X",
+ // streamHandle);
+ }
reply->writeInt32(streamHandle);
configuration.writeToParcel(reply);
return NO_ERROR;