From e7f81f45c82bc8a2c31ed1021f89eb20da3a7620 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 17 Jan 2022 15:11:37 +0100 Subject: [PATCH] Add patch to avoid segfault in bluez5 (rhbz#2041481) --- 0003-audioconvert-avoid-infinite-loop.patch | 48 +++++++++++++++++++ ...missing-device-and-adapter-in-quirks.patch | 38 +++++++++++++++ pipewire.spec | 7 ++- 3 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 0003-audioconvert-avoid-infinite-loop.patch create mode 100644 0004-bluez5-handle-missing-device-and-adapter-in-quirks.patch diff --git a/0003-audioconvert-avoid-infinite-loop.patch b/0003-audioconvert-avoid-infinite-loop.patch new file mode 100644 index 0000000..8b43205 --- /dev/null +++ b/0003-audioconvert-avoid-infinite-loop.patch @@ -0,0 +1,48 @@ +From 30ea2a9682727f64857537c5b36b65cf6425b005 Mon Sep 17 00:00:00 2001 +From: Wim Taymans +Date: Wed, 5 Jan 2022 17:02:40 +0100 +Subject: [PATCH 3/4] audioconvert: avoid infinite loop + +When the follower has no param to enumerate we would keep on enumerating +the params of the converter forever. Fix this by setting the next value +to something that would then stop the iteration. + +Also increase the amount of bits for the follower because it might need +them. +--- + spa/plugins/audioconvert/audioadapter.c | 11 ++++++----- + 1 file changed, 6 insertions(+), 5 deletions(-) + +diff --git a/spa/plugins/audioconvert/audioadapter.c b/spa/plugins/audioconvert/audioadapter.c +index b7f80feca..34622a66c 100644 +--- a/spa/plugins/audioconvert/audioadapter.c ++++ b/spa/plugins/audioconvert/audioadapter.c +@@ -118,19 +118,20 @@ static int follower_enum_params(struct impl *this, + struct spa_pod_builder *builder) + { + int res; +- if (result->next < 0x10000) { ++ if (result->next < 0x100000) { + if ((res = spa_node_enum_params_sync(this->convert, + id, &result->next, filter, &result->param, builder)) == 1) + return res; +- result->next = 0x10000; ++ result->next = 0x100000; + } +- if (result->next >= 0x10000 && this->follower_params_flags[idx] & SPA_PARAM_INFO_READ) { +- result->next &= 0xffff; ++ if (result->next < 0x200000 && this->follower_params_flags[idx] & SPA_PARAM_INFO_READ) { ++ result->next &= 0xfffff; + if ((res = spa_node_enum_params_sync(this->follower, + id, &result->next, filter, &result->param, builder)) == 1) { +- result->next |= 0x10000; ++ result->next |= 0x100000; + return res; + } ++ result->next = 0x200000; + } + return 0; + } +-- +2.31.1 + diff --git a/0004-bluez5-handle-missing-device-and-adapter-in-quirks.patch b/0004-bluez5-handle-missing-device-and-adapter-in-quirks.patch new file mode 100644 index 0000000..e6b36a6 --- /dev/null +++ b/0004-bluez5-handle-missing-device-and-adapter-in-quirks.patch @@ -0,0 +1,38 @@ +From a85ed47bb50c70384c37d4896a41596921c8d674 Mon Sep 17 00:00:00 2001 +From: Wim Taymans +Date: Tue, 11 Jan 2022 21:33:35 +0100 +Subject: [PATCH 4/4] bluez5: handle missing device and adapter in quirks + +When the device or adapter is NULL, skip the quirk checks instead of +crashing. + +Fixes https://gitlab.freedesktop.org/pipewire/wireplumber/-/issues/155 +--- + spa/plugins/bluez5/quirks.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/spa/plugins/bluez5/quirks.c b/spa/plugins/bluez5/quirks.c +index 217bb61f6..16a8ebaa9 100644 +--- a/spa/plugins/bluez5/quirks.c ++++ b/spa/plugins/bluez5/quirks.c +@@ -332,7 +332,7 @@ int spa_bt_quirks_get_features(const struct spa_bt_quirks *this, + } + + /* Adapter */ +- if (this->adapter_rules) { ++ if (this->adapter_rules && adapter) { + uint32_t no_features = 0; + int nitems = 0; + char vendor_id[64], product_id[64], address[64]; +@@ -357,7 +357,7 @@ int spa_bt_quirks_get_features(const struct spa_bt_quirks *this, + } + + /* Device */ +- if (this->device_rules) { ++ if (this->device_rules && device) { + uint32_t no_features = 0; + int nitems = 0; + char vendor_id[64], product_id[64], version_id[64], address[64]; +-- +2.31.1 + diff --git a/pipewire.spec b/pipewire.spec index 922a037..cb6f57c 100644 --- a/pipewire.spec +++ b/pipewire.spec @@ -9,7 +9,7 @@ %global ms_version 0.4.1 # For rpmdev-bumpspec and releng automation -%global baserelease 1 +%global baserelease 2 #global snapdate 20210107 #global gitcommit b17db2cebc1a5ab2c01851d29c05f79cd2f262bb @@ -73,6 +73,8 @@ Source1: https://gitlab.freedesktop.org/pipewire/media-session/-/archive/ %endif ## upstream patches +Patch0001: 0003-audioconvert-avoid-infinite-loop.patch +Patch0002: 0004-bluez5-handle-missing-device-and-adapter-in-quirks.patch ## upstreamable patches @@ -602,6 +604,9 @@ systemctl --no-reload preset --global pipewire.socket >/dev/null 2>&1 || : %endif %changelog +* Mon Jan 17 2022 Wim Taymans - 0.3.43-2 +- Add patch to avoid segfault in bluez5 (rhbz#2041481) + * Wed Jan 5 2022 Wim Taymans - 0.3.43-1 - Update version to 0.3.43