diff options
author | Arun Raghavan <arun@arunraghavan.net> | 2017-09-13 12:49:28 +0530 |
---|---|---|
committer | Arun Raghavan <arun@arunraghavan.net> | 2017-09-13 12:49:28 +0530 |
commit | 01f489c396ac3adfb95d57be48bc9f5b5a2a76c6 (patch) | |
tree | a5da5e5cd0b7292b0062c130bc053c24833fd81e | |
parent | 9e895b172569ce5c34d977dbb7fded8c7957782e (diff) | |
download | pulseaudio-01f489c396ac3adfb95d57be48bc9f5b5a2a76c6.tar.gz |
bluez: Don't crash on strange MTU sizes
We got reports of this with automatically detected MTUs that weren't
frame aligned.
-rw-r--r-- | src/modules/bluetooth/module-bluez5-device.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/modules/bluetooth/module-bluez5-device.c b/src/modules/bluetooth/module-bluez5-device.c index a37c3d54f..530207a28 100644 --- a/src/modules/bluetooth/module-bluez5-device.c +++ b/src/modules/bluetooth/module-bluez5-device.c @@ -787,6 +787,16 @@ static void transport_config_mtu(struct userdata *u) { if (u->profile == PA_BLUETOOTH_PROFILE_HEADSET_HEAD_UNIT || u->profile == PA_BLUETOOTH_PROFILE_HEADSET_AUDIO_GATEWAY) { u->read_block_size = u->read_link_mtu; u->write_block_size = u->write_link_mtu; + + if (!pa_frame_aligned(u->read_block_size, &u->source->sample_spec)) { + pa_log_debug("Got invalid read MTU: %lu, rounding down", u->read_block_size); + u->read_block_size = pa_frame_align(u->read_block_size, &u->source->sample_spec); + } + + if (!pa_frame_aligned(u->write_block_size, &u->sink->sample_spec)) { + pa_log_debug("Got invalid write MTU: %lu, rounding down", u->write_block_size); + u->write_block_size = pa_frame_align(u->write_block_size, &u->sink->sample_spec); + } } else { u->read_block_size = (u->read_link_mtu - sizeof(struct rtp_header) - sizeof(struct rtp_payload)) |