Check stream type in AudioFlinger::createTrack
A bad parameter to AudioFlinger::createTrack could cause mediaserver to crash.
Other AudioFlinger stream type cleanup:
- Simplify range check for audio_stream_type_t
- Add comment about mStreamTypes array initialization.
Change-Id: Ia33aa1cce0fdd694b08d9288816ffc097a9543d0
diff --git a/services/audioflinger/AudioPolicyService.cpp b/services/audioflinger/AudioPolicyService.cpp
index b06bcb9..44311d0 100644
--- a/services/audioflinger/AudioPolicyService.cpp
+++ b/services/audioflinger/AudioPolicyService.cpp
@@ -400,7 +400,7 @@
if (!checkPermission()) {
return PERMISSION_DENIED;
}
- if (stream < 0 || stream >= AUDIO_STREAM_CNT) {
+ if (uint32_t(stream) >= AUDIO_STREAM_CNT) {
return BAD_VALUE;
}
mpAudioPolicy->init_stream_volume(mpAudioPolicy, stream, indexMin, indexMax);
@@ -415,7 +415,7 @@
if (!checkPermission()) {
return PERMISSION_DENIED;
}
- if (stream < 0 || stream >= AUDIO_STREAM_CNT) {
+ if (uint32_t(stream) >= AUDIO_STREAM_CNT) {
return BAD_VALUE;
}
@@ -427,7 +427,7 @@
if (mpAudioPolicy == NULL) {
return NO_INIT;
}
- if (stream < 0 || stream >= AUDIO_STREAM_CNT) {
+ if (uint32_t(stream) >= AUDIO_STREAM_CNT) {
return BAD_VALUE;
}
return mpAudioPolicy->get_stream_volume_index(mpAudioPolicy, stream, index);