summaryrefslogtreecommitdiff
path: root/audio/core/all-versions/default/StreamIn.cpp
diff options
context:
space:
mode:
authorKevin Rocard <krocard@google.com>2019-05-20 15:04:49 -0700
committerKevin Rocard <krocard@google.com>2019-05-21 00:27:09 +0000
commitdbb7d0d3049feb2151fec510a4002ff5068262cf (patch)
tree897637034d164acf3d374abb5dde2f67af1a9d86 /audio/core/all-versions/default/StreamIn.cpp
parent9ace2c9788797abf7f688028d5e25f8388200fa0 (diff)
Validate HAL mic input
Input value were not checked, resulting in out of range input accepted. This was checked by test but never implemented in the default HAL. Bug: 133105753 Test: atest VtsHalAudioV5_0Target Change-Id: Ie6dae638b60daff6923668dc9637067f29e48b21 Signed-off-by: Kevin Rocard <krocard@google.com>
Diffstat (limited to 'audio/core/all-versions/default/StreamIn.cpp')
-rw-r--r--audio/core/all-versions/default/StreamIn.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/audio/core/all-versions/default/StreamIn.cpp b/audio/core/all-versions/default/StreamIn.cpp
index daba6f7ef2..d316f83617 100644
--- a/audio/core/all-versions/default/StreamIn.cpp
+++ b/audio/core/all-versions/default/StreamIn.cpp
@@ -19,6 +19,7 @@
#include "core/default/StreamIn.h"
#include "core/default/Conversions.h"
#include "core/default/Util.h"
+#include "common/all-versions/HidlSupport.h"
//#define LOG_NDEBUG 0
#define ATRACE_TAG ATRACE_TAG_AUDIO
@@ -27,6 +28,7 @@
#include <hardware/audio.h>
#include <utils/Trace.h>
#include <memory>
+#include <cmath>
namespace android {
namespace hardware {
@@ -501,6 +503,10 @@ Return<Result> StreamIn::setMicrophoneDirection(MicrophoneDirection direction) {
if (mStream->set_microphone_direction == nullptr) {
return Result::NOT_SUPPORTED;
}
+ if (!common::utils::isValidHidlEnum(direction)) {
+ ALOGE("%s: Invalid direction %d", __func__, direction);
+ return Result::INVALID_ARGUMENTS;
+ }
return Stream::analyzeStatus(
"set_microphone_direction",
mStream->set_microphone_direction(
@@ -511,6 +517,10 @@ Return<Result> StreamIn::setMicrophoneFieldDimension(float zoom) {
if (mStream->set_microphone_field_dimension == nullptr) {
return Result::NOT_SUPPORTED;
}
+ if (std::isnan(zoom) || zoom < -1 || zoom > 1) {
+ ALOGE("%s: Invalid zoom %f", __func__, zoom);
+ return Result::INVALID_ARGUMENTS;
+ }
return Stream::analyzeStatus("set_microphone_field_dimension",
mStream->set_microphone_field_dimension(mStream, zoom));
}