diff options
author | Glenn Kasten <gkasten@google.com> | 2014-11-05 17:34:39 -0800 |
---|---|---|
committer | Glenn Kasten <gkasten@google.com> | 2014-11-06 18:04:41 -0800 |
commit | 2d2ea50df16fc1a04f1ebf8772c65c56e4f5ecfa (patch) | |
tree | 38d9bfbbc01bcc8ddc26ea01fa799e95b7165756 | |
parent | 8ddf81e20fd514907de51ec82a617143d2e35276 (diff) | |
download | hardware_libhardware_legacy-2d2ea50df16fc1a04f1ebf8772c65c56e4f5ecfa.zip hardware_libhardware_legacy-2d2ea50df16fc1a04f1ebf8772c65c56e4f5ecfa.tar.gz hardware_libhardware_legacy-2d2ea50df16fc1a04f1ebf8772c65c56e4f5ecfa.tar.bz2 |
legacy audio policy: check string parameters before use
Bug: 18262893
Change-Id: Iee6e59db7ffae5612256ba1f74aba62bc8cf12db
-rw-r--r-- | audio/AudioPolicyManagerBase.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/audio/AudioPolicyManagerBase.cpp b/audio/AudioPolicyManagerBase.cpp index 1d49abb..c03224a 100644 --- a/audio/AudioPolicyManagerBase.cpp +++ b/audio/AudioPolicyManagerBase.cpp @@ -53,6 +53,11 @@ status_t AudioPolicyManagerBase::setDeviceConnectionState(audio_devices_t device AudioSystem::device_connection_state state, const char *device_address) { + // device_address can be NULL and should be handled as an empty string in this case, + // and it is not checked by AudioPolicyInterfaceImpl.cpp + if (device_address == NULL) { + device_address = ""; + } ALOGV("setDeviceConnectionState() device: 0x%X, state %d, address %s", device, state, device_address); // connect/disconnect only 1 device at a time @@ -245,6 +250,10 @@ status_t AudioPolicyManagerBase::setDeviceConnectionState(audio_devices_t device AudioSystem::device_connection_state AudioPolicyManagerBase::getDeviceConnectionState(audio_devices_t device, const char *device_address) { + // similar to setDeviceConnectionState + if (device_address == NULL) { + device_address = ""; + } AudioSystem::device_connection_state state = AudioSystem::DEVICE_STATE_UNAVAILABLE; String8 address = String8(device_address); if (audio_is_output_device(device)) { |