From a0d806dea6bc03ba1464152142baa8b6fd0f2a61 Mon Sep 17 00:00:00 2001 From: Bernd Kuhls Date: Sun, 20 Mar 2022 12:54:01 +0100 Subject: [PATCH] package/{bluez5_utils, bluez5_utils-headers}: bump to version 5.64 Removed all patches after being applied upstream: https://git.kernel.org/pub/scm/bluetooth/bluez.git/commit/?id=ec8c8f22efb66ccae533fbd55a236570ffcf756c https://git.kernel.org/pub/scm/bluetooth/bluez.git/commit/?id=710220f861b100856711a0a4d4a852874228a57a https://git.kernel.org/pub/scm/bluetooth/bluez.git/commit/?id=9f09e69ecb077082301dafb745856e1f3731aaa7 https://git.kernel.org/pub/scm/bluetooth/bluez.git/commit/?id=cfab569484b18407fc117bb96634525cc76ea1f5 https://git.kernel.org/pub/scm/bluetooth/bluez.git/commit/?id=fb57ad9b9d107856e5f1c8135da04ffa2f7a11ac https://git.kernel.org/pub/scm/bluetooth/bluez.git/commit/?id=58dec00edcaa316909cdd5309bd7bd3239ee221a Signed-off-by: Bernd Kuhls Signed-off-by: Thomas Petazzoni --- .../bluez5_utils-headers.mk | 2 +- ...-tools-mesh-cfgtest-include-limits.h.patch | 33 - ...til-Rename-btd_malloc-to-util_malloc.patch | 67 - .../0003-shared-util-Add-util_memdup.patch | 57 - ...ace-use-of-g_memdup-with-util_memdup.patch | 1411 ----------------- ...005-build-Fix-errors-with-glibc-2-25.patch | 312 ---- ...rc-shared-util.h-include-sys-types.h.patch | 39 - package/bluez5_utils/bluez5_utils.hash | 2 +- package/bluez5_utils/bluez5_utils.mk | 4 +- 9 files changed, 3 insertions(+), 1924 deletions(-) delete mode 100644 package/bluez5_utils/0001-tools-mesh-cfgtest-include-limits.h.patch delete mode 100644 package/bluez5_utils/0002-shared-util-Rename-btd_malloc-to-util_malloc.patch delete mode 100644 package/bluez5_utils/0003-shared-util-Add-util_memdup.patch delete mode 100644 package/bluez5_utils/0004-build-Replace-use-of-g_memdup-with-util_memdup.patch delete mode 100644 package/bluez5_utils/0005-build-Fix-errors-with-glibc-2-25.patch delete mode 100644 package/bluez5_utils/0006-src-shared-util.h-include-sys-types.h.patch diff --git a/package/bluez5_utils-headers/bluez5_utils-headers.mk b/package/bluez5_utils-headers/bluez5_utils-headers.mk index 5bfc652355..2f3a290ea8 100644 --- a/package/bluez5_utils-headers/bluez5_utils-headers.mk +++ b/package/bluez5_utils-headers/bluez5_utils-headers.mk @@ -5,7 +5,7 @@ ################################################################################ # Keep the version and patches in sync with bluez5_utils -BLUEZ5_UTILS_HEADERS_VERSION = 5.63 +BLUEZ5_UTILS_HEADERS_VERSION = 5.64 BLUEZ5_UTILS_HEADERS_SOURCE = bluez-$(BLUEZ5_UTILS_VERSION).tar.xz BLUEZ5_UTILS_HEADERS_SITE = $(BR2_KERNEL_MIRROR)/linux/bluetooth BLUEZ5_UTILS_HEADERS_DL_SUBDIR = bluez5_utils diff --git a/package/bluez5_utils/0001-tools-mesh-cfgtest-include-limits.h.patch b/package/bluez5_utils/0001-tools-mesh-cfgtest-include-limits.h.patch deleted file mode 100644 index 7f1197357f..0000000000 --- a/package/bluez5_utils/0001-tools-mesh-cfgtest-include-limits.h.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 5158827fded7cb4daf550a5956aff0c74f6c38fc Mon Sep 17 00:00:00 2001 -From: Michael Nosthoff -Date: Thu, 22 Jul 2021 21:36:13 +0200 -Subject: [PATCH] tools/mesh-cfgtest: include limits.h - -mesh-cfgtest.c uses PATH_MAX so it should include limits.h. - -fixes compilation error when enabling mesh support with musl-based -toolchains observed in buildroot autobuilders. - -http://autobuild.buildroot.net/results/20cc47f54de0b0d4bdf108c3715c590ae8ab476f/ -http://autobuild.buildroot.net/results/003968b25906579dbcf5a95d1e43fec0ab504ef5/ - -Signed-off-by: Michael Nosthoff ---- - tools/mesh-cfgtest.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/tools/mesh-cfgtest.c b/tools/mesh-cfgtest.c -index fa0474faa..116ab7f16 100644 ---- a/tools/mesh-cfgtest.c -+++ b/tools/mesh-cfgtest.c -@@ -21,6 +21,7 @@ - #include - #include - #include -+#include - #include - #include - #include --- -2.32.0 - diff --git a/package/bluez5_utils/0002-shared-util-Rename-btd_malloc-to-util_malloc.patch b/package/bluez5_utils/0002-shared-util-Rename-btd_malloc-to-util_malloc.patch deleted file mode 100644 index f8d74528d8..0000000000 --- a/package/bluez5_utils/0002-shared-util-Rename-btd_malloc-to-util_malloc.patch +++ /dev/null @@ -1,67 +0,0 @@ -From f3263fed28bf510a1225661fe2b5f598300c11cd Mon Sep 17 00:00:00 2001 -From: Luiz Augusto von Dentz -Date: Wed, 5 Jan 2022 15:53:35 -0800 -Subject: [PATCH] shared/util: Rename btd_malloc to util_malloc - -util functions are not limited to daemon only which is normally the case -when using btd prefix. - -(cherry picked from commit 710220f861b100856711a0a4d4a852874228a57a) -Signed-off-by: Thomas Devoogdt ---- - profiles/audio/avdtp.c | 2 +- - src/shared/util.c | 2 +- - src/shared/util.h | 4 ++-- - 3 files changed, 4 insertions(+), 4 deletions(-) - -diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c -index d3dfbf96d..f2b461330 100644 ---- a/profiles/audio/avdtp.c -+++ b/profiles/audio/avdtp.c -@@ -1333,7 +1333,7 @@ static GSList *caps_to_list(uint8_t *data, size_t size, - break; - } - -- cpy = btd_malloc(sizeof(*cpy) + cap->length); -+ cpy = util_malloc(sizeof(*cpy) + cap->length); - memcpy(cpy, cap, sizeof(*cap) + cap->length); - - size -= sizeof(*cap) + cap->length; -diff --git a/src/shared/util.c b/src/shared/util.c -index 81b20d86f..93110047b 100644 ---- a/src/shared/util.c -+++ b/src/shared/util.c -@@ -25,7 +25,7 @@ - - #include "src/shared/util.h" - --void *btd_malloc(size_t size) -+void *util_malloc(size_t size) - { - if (__builtin_expect(!!size, 1)) { - void *ptr; -diff --git a/src/shared/util.h b/src/shared/util.h -index ac70117ca..11d09979d 100644 ---- a/src/shared/util.h -+++ b/src/shared/util.h -@@ -75,7 +75,7 @@ do { \ - size_t __n = (size_t) (count); \ - size_t __s = sizeof(type); \ - void *__p; \ -- __p = btd_malloc(__n * __s); \ -+ __p = util_malloc(__n * __s); \ - memset(__p, 0, __n * __s); \ - __p; \ - })) -@@ -86,7 +86,7 @@ do { \ - char *strdelimit(char *str, char *del, char c); - int strsuffix(const char *str, const char *suffix); - --void *btd_malloc(size_t size); -+void *util_malloc(size_t size); - - typedef void (*util_debug_func_t)(const char *str, void *user_data); - --- -2.17.1 - diff --git a/package/bluez5_utils/0003-shared-util-Add-util_memdup.patch b/package/bluez5_utils/0003-shared-util-Add-util_memdup.patch deleted file mode 100644 index d5c31a2614..0000000000 --- a/package/bluez5_utils/0003-shared-util-Add-util_memdup.patch +++ /dev/null @@ -1,57 +0,0 @@ -From 28f1c140374d1ecda65e3d59cca72352c3a07774 Mon Sep 17 00:00:00 2001 -From: Luiz Augusto von Dentz -Date: Thu, 6 Jan 2022 11:45:12 -0800 -Subject: [PATCH] shared/util: Add util_memdup - -This adds util_memdup which is intended to replace g_memdup since -replacing that with g_memdup2 requires bumping the glib version. - -(cherry picked from commit 9f09e69ecb077082301dafb745856e1f3731aaa7) -Signed-off-by: Thomas Devoogdt ---- - src/shared/util.c | 16 ++++++++++++++++ - src/shared/util.h | 1 + - 2 files changed, 17 insertions(+) - -diff --git a/src/shared/util.c b/src/shared/util.c -index 93110047b..6e1c83057 100644 ---- a/src/shared/util.c -+++ b/src/shared/util.c -@@ -41,6 +41,22 @@ void *util_malloc(size_t size) - return NULL; - } - -+void *util_memdup(const void *src, size_t size) -+{ -+ void *cpy; -+ -+ if (!src || !size) -+ return NULL; -+ -+ cpy = util_malloc(size); -+ if (!cpy) -+ return NULL; -+ -+ memcpy(cpy, src, size); -+ -+ return cpy; -+} -+ - void util_debug_va(util_debug_func_t function, void *user_data, - const char *format, va_list va) - { -diff --git a/src/shared/util.h b/src/shared/util.h -index 11d09979d..8ef6132c4 100644 ---- a/src/shared/util.h -+++ b/src/shared/util.h -@@ -87,6 +87,7 @@ char *strdelimit(char *str, char *del, char c); - int strsuffix(const char *str, const char *suffix); - - void *util_malloc(size_t size); -+void *util_memdup(const void *src, size_t size); - - typedef void (*util_debug_func_t)(const char *str, void *user_data); - --- -2.17.1 - diff --git a/package/bluez5_utils/0004-build-Replace-use-of-g_memdup-with-util_memdup.patch b/package/bluez5_utils/0004-build-Replace-use-of-g_memdup-with-util_memdup.patch deleted file mode 100644 index 9e1047c957..0000000000 --- a/package/bluez5_utils/0004-build-Replace-use-of-g_memdup-with-util_memdup.patch +++ /dev/null @@ -1,1411 +0,0 @@ -From 7eb74180cf6fd6cebc61bb719d458cbf5d7f4ca7 Mon Sep 17 00:00:00 2001 -From: Luiz Augusto von Dentz -Date: Thu, 6 Jan 2022 12:50:33 -0800 -Subject: [PATCH] build: Replace use of g_memdup with util_memdup -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -This replaces the uses of g_memdup with util_memdup since the former has -been deprecated: - - warning: ‘g_memdup’ is deprecated: Use 'g_memdup2' instead - [-Wdeprecated-declarations] - -g_memdup2 requires bumping glib version which would likely have its -own problems thus why util_memdup was introduced. - -(cherry picked from commit cfab569484b18407fc117bb96634525cc76ea1f5) -Signed-off-by: Thomas Devoogdt ---- - Makefile.am | 10 ++--- - Makefile.obexd | 1 + - Makefile.tools | 11 ++++-- - android/a2dp.c | 9 +++-- - android/avctp.c | 5 ++- - android/avrcp-lib.c | 2 +- - android/gatt.c | 5 ++- - android/hidhost.c | 3 +- - android/tester-main.c | 77 +++++++++++++++++++++----------------- - attrib/gatt.c | 12 +++--- - client/gatt.c | 2 +- - gobex/gobex-header.c | 7 ++-- - gobex/gobex-packet.c | 5 ++- - obexd/src/obex.c | 5 ++- - plugins/neard.c | 9 +++-- - plugins/policy.c | 7 ++-- - profiles/audio/avctp.c | 9 +++-- - profiles/audio/avrcp.c | 10 ++--- - profiles/battery/bas.c | 4 +- - profiles/battery/battery.c | 4 +- - profiles/deviceinfo/dis.c | 4 +- - profiles/input/hog-lib.c | 12 +++--- - profiles/scanparam/scpp.c | 4 +- - src/eir.c | 8 ++-- - tools/gatt-service.c | 15 ++++---- - tools/mesh-gatt/gatt.c | 5 ++- - unit/test-avctp.c | 4 +- - unit/test-avdtp.c | 6 +-- - unit/test-avrcp.c | 10 ++--- - unit/test-gatt.c | 4 +- - unit/test-hfp.c | 11 +++--- - unit/test-hog.c | 26 ++++++------- - unit/test-sdp.c | 10 +++-- - unit/test-uhid.c | 2 +- - 34 files changed, 172 insertions(+), 146 deletions(-) - -diff --git a/Makefile.am b/Makefile.am -index 308f13c50..9b5e140b8 100644 ---- a/Makefile.am -+++ b/Makefile.am -@@ -508,23 +508,23 @@ unit_tests += unit/test-gobex-header unit/test-gobex-packet unit/test-gobex \ - - unit_test_gobex_SOURCES = $(gobex_sources) unit/util.c unit/util.h \ - unit/test-gobex.c --unit_test_gobex_LDADD = $(GLIB_LIBS) -+unit_test_gobex_LDADD = src/libshared-glib.la $(GLIB_LIBS) - - unit_test_gobex_packet_SOURCES = $(gobex_sources) unit/util.c unit/util.h \ - unit/test-gobex-packet.c --unit_test_gobex_packet_LDADD = $(GLIB_LIBS) -+unit_test_gobex_packet_LDADD = src/libshared-glib.la $(GLIB_LIBS) - - unit_test_gobex_header_SOURCES = $(gobex_sources) unit/util.c unit/util.h \ - unit/test-gobex-header.c --unit_test_gobex_header_LDADD = $(GLIB_LIBS) -+unit_test_gobex_header_LDADD = src/libshared-glib.la $(GLIB_LIBS) - - unit_test_gobex_transfer_SOURCES = $(gobex_sources) unit/util.c unit/util.h \ - unit/test-gobex-transfer.c --unit_test_gobex_transfer_LDADD = $(GLIB_LIBS) -+unit_test_gobex_transfer_LDADD = src/libshared-glib.la $(GLIB_LIBS) - - unit_test_gobex_apparam_SOURCES = $(gobex_sources) unit/util.c unit/util.h \ - unit/test-gobex-apparam.c --unit_test_gobex_apparam_LDADD = $(GLIB_LIBS) -+unit_test_gobex_apparam_LDADD = src/libshared-glib.la $(GLIB_LIBS) - endif - - unit_tests += unit/test-lib -diff --git a/Makefile.obexd b/Makefile.obexd -index 37a133455..5d1a4ff65 100644 ---- a/Makefile.obexd -+++ b/Makefile.obexd -@@ -82,6 +82,7 @@ obexd_src_obexd_SOURCES = $(btio_sources) $(gobex_sources) \ - obexd/src/map_ap.h - obexd_src_obexd_LDADD = lib/libbluetooth-internal.la \ - gdbus/libgdbus-internal.la \ -+ src/libshared-glib.la \ - $(ICAL_LIBS) $(DBUS_LIBS) $(LIBEBOOK_LIBS) \ - $(LIBEDATASERVER_LIBS) $(GLIB_LIBS) -ldl - -diff --git a/Makefile.tools b/Makefile.tools -index c7bdff83f..35b0021ea 100644 ---- a/Makefile.tools -+++ b/Makefile.tools -@@ -302,7 +302,8 @@ tools_mpris_proxy_SOURCES = tools/mpris-proxy.c - tools_mpris_proxy_LDADD = gdbus/libgdbus-internal.la $(GLIB_LIBS) $(DBUS_LIBS) - - tools_gatt_service_SOURCES = tools/gatt-service.c --tools_gatt_service_LDADD = $(GLIB_LIBS) $(DBUS_LIBS) gdbus/libgdbus-internal.la -+tools_gatt_service_LDADD = gdbus/libgdbus-internal.la \ -+ src/libshared-mainloop.la $(GLIB_LIBS) $(DBUS_LIBS) - - profiles_iap_iapd_SOURCES = profiles/iap/main.c - profiles_iap_iapd_LDADD = gdbus/libgdbus-internal.la $(GLIB_LIBS) $(DBUS_LIBS) -@@ -448,11 +449,12 @@ noinst_PROGRAMS += tools/btmgmt tools/obex-client-tool tools/obex-server-tool \ - tools_obex_client_tool_SOURCES = $(gobex_sources) $(btio_sources) \ - tools/obex-client-tool.c - tools_obex_client_tool_LDADD = lib/libbluetooth-internal.la \ -- $(GLIB_LIBS) -lreadline -+ src/libshared-glib.la $(GLIB_LIBS) -lreadline - - tools_obex_server_tool_SOURCES = $(gobex_sources) $(btio_sources) \ - tools/obex-server-tool.c --tools_obex_server_tool_LDADD = lib/libbluetooth-internal.la $(GLIB_LIBS) -+tools_obex_server_tool_LDADD = lib/libbluetooth-internal.la \ -+ src/libshared-glib.la $(GLIB_LIBS) - - tools_bluetooth_player_SOURCES = tools/bluetooth-player.c - tools_bluetooth_player_LDADD = gdbus/libgdbus-internal.la \ -@@ -461,7 +463,8 @@ tools_bluetooth_player_LDADD = gdbus/libgdbus-internal.la \ - - tools_obexctl_SOURCES = tools/obexctl.c - tools_obexctl_LDADD = gdbus/libgdbus-internal.la src/libshared-glib.la \ -- $(GLIB_LIBS) $(DBUS_LIBS) -lreadline -+ src/libshared-glib.la $(GLIB_LIBS) $(DBUS_LIBS) \ -+ -lreadline - - tools_btmgmt_SOURCES = tools/btmgmt.c src/uuid-helper.c client/display.c - tools_btmgmt_LDADD = lib/libbluetooth-internal.la src/libshared-mainloop.la \ -diff --git a/android/a2dp.c b/android/a2dp.c -index 029107cf5..ee607a32d 100644 ---- a/android/a2dp.c -+++ b/android/a2dp.c -@@ -26,6 +26,7 @@ - #include "lib/sdp_lib.h" - #include "profiles/audio/a2dp-codecs.h" - #include "src/shared/queue.h" -+#include "src/shared/util.h" - #include "src/log.h" - #include "hal-msg.h" - #include "ipc-common.h" -@@ -428,7 +429,7 @@ static struct a2dp_preset *sbc_select_range(void *caps, uint8_t caps_len, - - p = g_new0(struct a2dp_preset, 1); - p->len = conf_len; -- p->data = g_memdup(conf, p->len); -+ p->data = util_memdup(conf, p->len); - - return p; - } -@@ -448,7 +449,7 @@ static struct a2dp_preset *aac_select_range(void *caps, uint8_t caps_len, - - p = g_new0(struct a2dp_preset, 1); - p->len = conf_len; -- p->data = g_memdup(conf, p->len); -+ p->data = util_memdup(conf, p->len); - - return p; - } -@@ -1036,7 +1037,7 @@ static gboolean sep_setconf_ind(struct avdtp *session, - - preset = g_new0(struct a2dp_preset, 1); - preset->len = cap->length - sizeof(*codec); -- preset->data = g_memdup(codec->data, preset->len); -+ preset->data = util_memdup(codec->data, preset->len); - - if (check_config(endpoint, preset) < 0) { - preset_free(preset); -@@ -1365,7 +1366,7 @@ static GSList *parse_presets(const struct audio_preset *p, uint8_t count, - - preset = g_new0(struct a2dp_preset, 1); - preset->len = p->len; -- preset->data = g_memdup(p->data, preset->len); -+ preset->data = util_memdup(p->data, preset->len); - l = g_slist_append(l, preset); - - len -= preset->len; -diff --git a/android/avctp.c b/android/avctp.c -index 14ebbc391..37b4cec4f 100644 ---- a/android/avctp.c -+++ b/android/avctp.c -@@ -31,6 +31,7 @@ - #include - - #include "lib/sdp.h" -+#include "src/shared/util.h" - #include "src/log.h" - #include "avctp.h" - -@@ -1177,7 +1178,7 @@ static int avctp_send_req(struct avctp *session, uint8_t code, uint8_t subunit, - - for (i = 0; i < iov_cnt; i++) { - pdu[i].iov_len = iov[i].iov_len; -- pdu[i].iov_base = g_memdup(iov[i].iov_base, iov[i].iov_len); -+ pdu[i].iov_base = util_memdup(iov[i].iov_base, iov[i].iov_len); - } - - req = g_new0(struct avctp_control_req, 1); -@@ -1218,7 +1219,7 @@ int avctp_send_browsing_req(struct avctp *session, - - for (i = 0; i < iov_cnt; i++) { - pdu[i].iov_len = iov[i].iov_len; -- pdu[i].iov_base = g_memdup(iov[i].iov_base, iov[i].iov_len); -+ pdu[i].iov_base = util_memdup(iov[i].iov_base, iov[i].iov_len); - } - - req = g_new0(struct avctp_browsing_req, 1); -diff --git a/android/avrcp-lib.c b/android/avrcp-lib.c -index 2007d09d2..b342692cb 100644 ---- a/android/avrcp-lib.c -+++ b/android/avrcp-lib.c -@@ -2620,7 +2620,7 @@ static char *parse_folder_list(uint8_t *params, uint16_t params_len, - return NULL; - } - -- folders[count] = g_memdup(¶ms[i], len); -+ folders[count] = util_memdup(¶ms[i], len); - i += len; - } - -diff --git a/android/gatt.c b/android/gatt.c -index a8a0c488b..e8ba5aabb 100644 ---- a/android/gatt.c -+++ b/android/gatt.c -@@ -1338,7 +1338,8 @@ static void discover_primary_cb(uint8_t status, GSList *services, - } - - bt_uuid_to_uuid128(&uuid, &u128); -- new_uuid = g_memdup(&u128.value.u128, sizeof(u128.value.u128)); -+ new_uuid = util_memdup(&u128.value.u128, -+ sizeof(u128.value.u128)); - - uuids = g_slist_prepend(uuids, new_uuid); - } -@@ -6633,7 +6634,7 @@ static uint8_t write_prep_request(const uint8_t *cmd, uint16_t cmd_len, - - queue_push_tail(dev->pending_requests, data); - -- data->value = g_memdup(value, vlen); -+ data->value = util_memdup(value, vlen); - data->length = vlen; - - if (!gatt_db_attribute_write(attrib, offset, value, vlen, cmd[0], -diff --git a/android/hidhost.c b/android/hidhost.c -index 016382e17..b4e5c527f 100644 ---- a/android/hidhost.c -+++ b/android/hidhost.c -@@ -689,7 +689,8 @@ static void hid_sdp_search_cb(sdp_list_t *recs, int err, gpointer data) - goto fail; - - dev->rd_size = data->unitSize; -- dev->rd_data = g_memdup(data->val.str, data->unitSize); -+ dev->rd_data = util_memdup(data->val.str, -+ data->unitSize); - } - } - -diff --git a/android/tester-main.c b/android/tester-main.c -index ff5ecdf83..317c1de06 100644 ---- a/android/tester-main.c -+++ b/android/tester-main.c -@@ -1253,7 +1253,8 @@ static bt_property_t *copy_properties(int num_properties, - for (i = 0; i < num_properties; i++) { - props[i].type = properties[i].type; - props[i].len = properties[i].len; -- props[i].val = g_memdup(properties[i].val, properties[i].len); -+ props[i].val = util_memdup(properties[i].val, -+ properties[i].len); - } - - return props; -@@ -1268,7 +1269,8 @@ static bt_property_t *repack_properties(int num_properties, - for (i = 0; i < num_properties; i++) { - props[i].type = properties[i]->type; - props[i].len = properties[i]->len; -- props[i].val = g_memdup(properties[i]->val, properties[i]->len); -+ props[i].val = util_memdup(properties[i]->val, -+ properties[i]->len); - } - - return props; -@@ -1281,7 +1283,7 @@ static bt_property_t *create_property(bt_property_type_t type, void *val, - - prop->type = type; - prop->len = len; -- prop->val = g_memdup(val, len); -+ prop->val = util_memdup(val, len); - - return prop; - } -@@ -1615,7 +1617,7 @@ static void gattc_search_result_cb(int conn_id, btgatt_srvc_id_t *srvc_id) - - step->callback = CB_GATTC_SEARCH_RESULT; - step->callback_result.conn_id = conn_id; -- step->callback_result.service = g_memdup(srvc_id, sizeof(*srvc_id)); -+ step->callback_result.service = util_memdup(srvc_id, sizeof(*srvc_id)); - - schedule_callback_verification(step); - } -@@ -1639,8 +1641,8 @@ static void gattc_get_characteristic_cb(int conn_id, int status, - step->callback = CB_GATTC_GET_CHARACTERISTIC; - step->callback_result.status = status; - step->callback_result.conn_id = conn_id; -- step->callback_result.service = g_memdup(srvc_id, sizeof(*srvc_id)); -- step->callback_result.characteristic = g_memdup(char_id, -+ step->callback_result.service = util_memdup(srvc_id, sizeof(*srvc_id)); -+ step->callback_result.characteristic = util_memdup(char_id, - sizeof(*char_id)); - step->callback_result.char_prop = char_prop; - -@@ -1656,10 +1658,10 @@ static void gattc_get_descriptor_cb(int conn_id, int status, - step->callback = CB_GATTC_GET_DESCRIPTOR; - step->callback_result.status = status; - step->callback_result.conn_id = conn_id; -- step->callback_result.service = g_memdup(srvc_id, sizeof(*srvc_id)); -- step->callback_result.characteristic = g_memdup(char_id, -+ step->callback_result.service = util_memdup(srvc_id, sizeof(*srvc_id)); -+ step->callback_result.characteristic = util_memdup(char_id, - sizeof(*char_id)); -- step->callback_result.descriptor = g_memdup(descr_id, -+ step->callback_result.descriptor = util_memdup(descr_id, - sizeof(*descr_id)); - - schedule_callback_verification(step); -@@ -1673,8 +1675,8 @@ static void gattc_get_included_service_cb(int conn_id, int status, - step->callback = CB_GATTC_GET_INCLUDED_SERVICE; - step->callback_result.status = status; - step->callback_result.conn_id = conn_id; -- step->callback_result.service = g_memdup(srvc_id, sizeof(*srvc_id)); -- step->callback_result.included = g_memdup(incl_srvc_id, -+ step->callback_result.service = util_memdup(srvc_id, sizeof(*srvc_id)); -+ step->callback_result.included = util_memdup(incl_srvc_id, - sizeof(*srvc_id)); - - schedule_callback_verification(step); -@@ -1688,7 +1690,8 @@ static void gattc_read_characteristic_cb(int conn_id, int status, - step->callback = CB_GATTC_READ_CHARACTERISTIC; - step->callback_result.status = status; - step->callback_result.conn_id = conn_id; -- step->callback_result.read_params = g_memdup(p_data, sizeof(*p_data)); -+ step->callback_result.read_params = util_memdup(p_data, -+ sizeof(*p_data)); - - schedule_callback_verification(step); - } -@@ -1701,7 +1704,8 @@ static void gattc_read_descriptor_cb(int conn_id, int status, - step->callback = CB_GATTC_READ_DESCRIPTOR; - step->callback_result.status = status; - step->callback_result.conn_id = conn_id; -- step->callback_result.read_params = g_memdup(p_data, sizeof(*p_data)); -+ step->callback_result.read_params = util_memdup(p_data, -+ sizeof(*p_data)); - - schedule_callback_verification(step); - } -@@ -1714,7 +1718,8 @@ static void gattc_write_characteristic_cb(int conn_id, int status, - step->callback = CB_GATTC_WRITE_CHARACTERISTIC; - step->callback_result.status = status; - step->callback_result.conn_id = conn_id; -- step->callback_result.write_params = g_memdup(p_data, sizeof(*p_data)); -+ step->callback_result.write_params = util_memdup(p_data, -+ sizeof(*p_data)); - - schedule_callback_verification(step); - } -@@ -1727,7 +1732,8 @@ static void gattc_write_descriptor_cb(int conn_id, int status, - step->callback = CB_GATTC_WRITE_DESCRIPTOR; - step->callback_result.status = status; - step->callback_result.conn_id = conn_id; -- step->callback_result.write_params = g_memdup(p_data, sizeof(*p_data)); -+ step->callback_result.write_params = util_memdup(p_data, -+ sizeof(*p_data)); - - schedule_callback_verification(step); - } -@@ -1742,8 +1748,8 @@ static void gattc_register_for_notification_cb(int conn_id, int registered, - step->callback = CB_GATTC_REGISTER_FOR_NOTIFICATION; - step->callback_result.status = status; - step->callback_result.conn_id = conn_id; -- step->callback_result.service = g_memdup(srvc_id, sizeof(*srvc_id)); -- step->callback_result.characteristic = g_memdup(char_id, -+ step->callback_result.service = util_memdup(srvc_id, sizeof(*srvc_id)); -+ step->callback_result.characteristic = util_memdup(char_id, - sizeof(*char_id)); - step->callback_result.notification_registered = registered; - -@@ -1756,7 +1762,8 @@ static void gattc_notif_cb(int conn_id, btgatt_notify_params_t *p_data) - - step->callback = CB_GATTC_NOTIFY; - step->callback_result.conn_id = conn_id; -- step->callback_result.notify_params = g_memdup(p_data, sizeof(*p_data)); -+ step->callback_result.notify_params = util_memdup(p_data, -+ sizeof(*p_data)); - - schedule_callback_verification(step); - } -@@ -1827,8 +1834,8 @@ static void gatts_service_added_cb(int status, int server_if, - - step->callback_result.status = status; - step->callback_result.gatt_app_id = server_if; -- step->callback_result.service = g_memdup(srvc_id, sizeof(*srvc_id)); -- step->callback_result.srvc_handle = g_memdup(&srvc_handle, -+ step->callback_result.service = util_memdup(srvc_id, sizeof(*srvc_id)); -+ step->callback_result.srvc_handle = util_memdup(&srvc_handle, - sizeof(srvc_handle)); - - schedule_callback_verification(step); -@@ -1844,9 +1851,9 @@ static void gatts_included_service_added_cb(int status, int server_if, - - step->callback_result.status = status; - step->callback_result.gatt_app_id = server_if; -- step->callback_result.srvc_handle = g_memdup(&srvc_handle, -+ step->callback_result.srvc_handle = util_memdup(&srvc_handle, - sizeof(srvc_handle)); -- step->callback_result.inc_srvc_handle = g_memdup(&inc_srvc_handle, -+ step->callback_result.inc_srvc_handle = util_memdup(&inc_srvc_handle, - sizeof(inc_srvc_handle)); - - schedule_callback_verification(step); -@@ -1863,10 +1870,10 @@ static void gatts_characteristic_added_cb(int status, int server_if, - - step->callback_result.status = status; - step->callback_result.gatt_app_id = server_if; -- step->callback_result.srvc_handle = g_memdup(&srvc_handle, -+ step->callback_result.srvc_handle = util_memdup(&srvc_handle, - sizeof(srvc_handle)); -- step->callback_result.uuid = g_memdup(uuid, sizeof(*uuid)); -- step->callback_result.char_handle = g_memdup(&char_handle, -+ step->callback_result.uuid = util_memdup(uuid, sizeof(*uuid)); -+ step->callback_result.char_handle = util_memdup(&char_handle, - sizeof(char_handle)); - - schedule_callback_verification(step); -@@ -1883,10 +1890,10 @@ static void gatts_descriptor_added_cb(int status, int server_if, - - step->callback_result.status = status; - step->callback_result.gatt_app_id = server_if; -- step->callback_result.srvc_handle = g_memdup(&srvc_handle, -+ step->callback_result.srvc_handle = util_memdup(&srvc_handle, - sizeof(srvc_handle)); -- step->callback_result.uuid = g_memdup(uuid, sizeof(*uuid)); -- step->callback_result.desc_handle = g_memdup(&desc_handle, -+ step->callback_result.uuid = util_memdup(uuid, sizeof(*uuid)); -+ step->callback_result.desc_handle = util_memdup(&desc_handle, - sizeof(desc_handle)); - - schedule_callback_verification(step); -@@ -1900,7 +1907,7 @@ static void gatts_service_started_cb(int status, int server_if, int srvc_handle) - - step->callback_result.status = status; - step->callback_result.gatt_app_id = server_if; -- step->callback_result.srvc_handle = g_memdup(&srvc_handle, -+ step->callback_result.srvc_handle = util_memdup(&srvc_handle, - sizeof(srvc_handle)); - - schedule_callback_verification(step); -@@ -1914,7 +1921,7 @@ static void gatts_service_stopped_cb(int status, int server_if, int srvc_handle) - - step->callback_result.status = status; - step->callback_result.gatt_app_id = server_if; -- step->callback_result.srvc_handle = g_memdup(&srvc_handle, -+ step->callback_result.srvc_handle = util_memdup(&srvc_handle, - sizeof(srvc_handle)); - - schedule_callback_verification(step); -@@ -1928,7 +1935,7 @@ static void gatts_service_deleted_cb(int status, int server_if, int srvc_handle) - - step->callback_result.status = status; - step->callback_result.gatt_app_id = server_if; -- step->callback_result.srvc_handle = g_memdup(&srvc_handle, -+ step->callback_result.srvc_handle = util_memdup(&srvc_handle, - sizeof(srvc_handle)); - - schedule_callback_verification(step); -@@ -1945,7 +1952,7 @@ static void gatts_request_read_cb(int conn_id, int trans_id, bt_bdaddr_t *bda, - - step->callback_result.conn_id = conn_id; - step->callback_result.trans_id = trans_id; -- step->callback_result.attr_handle = g_memdup(&attr_handle, -+ step->callback_result.attr_handle = util_memdup(&attr_handle, - sizeof(attr_handle)); - step->callback_result.offset = offset; - step->callback_result.is_long = is_long; -@@ -1974,13 +1981,13 @@ static void gatts_request_write_cb(int conn_id, int trans_id, bt_bdaddr_t *bda, - - step->callback_result.conn_id = conn_id; - step->callback_result.trans_id = trans_id; -- step->callback_result.attr_handle = g_memdup(&attr_handle, -+ step->callback_result.attr_handle = util_memdup(&attr_handle, - sizeof(attr_handle)); - step->callback_result.offset = offset; - step->callback_result.length = length; - step->callback_result.need_rsp = need_rsp; - step->callback_result.is_prep = is_prep; -- step->callback_result.value = g_memdup(&value, length); -+ step->callback_result.value = util_memdup(&value, length); - - /* Utilize property verification mechanism for bdaddr */ - props[0] = create_property(BT_PROPERTY_BDADDR, bda, sizeof(*bda)); -@@ -2169,7 +2176,7 @@ static btmce_mas_instance_t *copy_mas_instances(int num_instances, - inst[i].id = instances[i].id; - inst[i].scn = instances[i].scn; - inst[i].msg_types = instances[i].msg_types; -- inst[i].p_name = g_memdup(instances[i].p_name, -+ inst[i].p_name = util_memdup(instances[i].p_name, - strlen(instances[i].p_name)); - } - -diff --git a/attrib/gatt.c b/attrib/gatt.c -index 46b2ca381..b496dd1eb 100644 ---- a/attrib/gatt.c -+++ b/attrib/gatt.c -@@ -135,7 +135,7 @@ static void discover_char_unref(void *data) - - g_slist_free_full(dc->characteristics, g_free); - g_attrib_unref(dc->attrib); -- g_free(dc->uuid); -+ free(dc->uuid); - g_free(dc); - } - -@@ -157,7 +157,7 @@ static void discover_desc_unref(void *data) - - g_slist_free_full(dd->descriptors, g_free); - g_attrib_unref(dd->attrib); -- g_free(dd->uuid); -+ free(dd->uuid); - g_free(dd); - } - -@@ -696,7 +696,7 @@ guint gatt_discover_char(GAttrib *attrib, uint16_t start, uint16_t end, - dc->user_data = user_data; - dc->end = end; - dc->start = start; -- dc->uuid = g_memdup(uuid, sizeof(bt_uuid_t)); -+ dc->uuid = util_memdup(uuid, sizeof(bt_uuid_t)); - - dc->id = g_attrib_send(attrib, 0, buf, plen, char_discovered_cb, - discover_char_ref(dc), discover_char_unref); -@@ -905,7 +905,7 @@ static void prepare_write_cb(guint8 status, const guint8 *rpdu, guint16 rlen, - if (long_write->offset == long_write->vlen) { - execute_write(long_write->attrib, ATT_WRITE_ALL_PREP_WRITES, - long_write->func, long_write->user_data); -- g_free(long_write->value); -+ free(long_write->value); - g_free(long_write); - - return; -@@ -964,7 +964,7 @@ guint gatt_write_char(GAttrib *attrib, uint16_t handle, const uint8_t *value, - long_write->func = func; - long_write->user_data = user_data; - long_write->handle = handle; -- long_write->value = g_memdup(value, vlen); -+ long_write->value = util_memdup(value, vlen); - long_write->vlen = vlen; - - return prepare_write(long_write); -@@ -1130,7 +1130,7 @@ guint gatt_discover_desc(GAttrib *attrib, uint16_t start, uint16_t end, - dd->user_data = user_data; - dd->start = start; - dd->end = end; -- dd->uuid = g_memdup(uuid, sizeof(bt_uuid_t)); -+ dd->uuid = util_memdup(uuid, sizeof(bt_uuid_t)); - - dd->id = g_attrib_send(attrib, 0, buf, plen, desc_discovered_cb, - discover_desc_ref(dd), discover_desc_unref); -diff --git a/client/gatt.c b/client/gatt.c -index 11f70dc4f..13872c794 100644 ---- a/client/gatt.c -+++ b/client/gatt.c -@@ -811,7 +811,7 @@ static uint8_t *str2bytearray(char *arg, size_t *val_len) - - *val_len = i; - -- return g_memdup(value, i); -+ return util_memdup(value, i); - } - - void gatt_write_attribute(GDBusProxy *proxy, int argc, char *argv[]) -diff --git a/gobex/gobex-header.c b/gobex/gobex-header.c -index 011d33d1a..002ba8861 100644 ---- a/gobex/gobex-header.c -+++ b/gobex/gobex-header.c -@@ -15,6 +15,7 @@ - - #include "gobex-header.h" - #include "gobex-debug.h" -+#include "src/shared/util.h" - - /* Header types */ - #define G_OBEX_HDR_ENC_UNICODE (0 << 6) -@@ -222,7 +223,7 @@ GObexHeader *g_obex_header_decode(const void *data, gsize len, - - switch (data_policy) { - case G_OBEX_DATA_COPY: -- header->v.data = g_memdup(ptr, header->vlen); -+ header->v.data = util_memdup(ptr, header->vlen); - break; - case G_OBEX_DATA_REF: - header->extdata = TRUE; -@@ -282,7 +283,7 @@ void g_obex_header_free(GObexHeader *header) - break; - case G_OBEX_HDR_ENC_BYTES: - if (!header->extdata) -- g_free(header->v.data); -+ free(header->v.data); - break; - case G_OBEX_HDR_ENC_UINT8: - case G_OBEX_HDR_ENC_UINT32: -@@ -410,7 +411,7 @@ GObexHeader *g_obex_header_new_bytes(guint8 id, const void *data, gsize len) - header->id = id; - header->vlen = len; - header->hlen = len + 3; -- header->v.data = g_memdup(data, len); -+ header->v.data = util_memdup(data, len); - - return header; - } -diff --git a/gobex/gobex-packet.c b/gobex/gobex-packet.c -index 11937a5a5..8ae78b0f6 100644 ---- a/gobex/gobex-packet.c -+++ b/gobex/gobex-packet.c -@@ -17,6 +17,7 @@ - #include "gobex-defs.h" - #include "gobex-packet.h" - #include "gobex-debug.h" -+#include "src/shared/util.h" - - #define FINAL_BIT 0x80 - -@@ -201,7 +202,7 @@ gboolean g_obex_packet_set_data(GObexPacket *pkt, const void *data, gsize len, - - switch (data_policy) { - case G_OBEX_DATA_COPY: -- pkt->data.buf = g_memdup(data, len); -+ pkt->data.buf = util_memdup(data, len); - break; - case G_OBEX_DATA_REF: - pkt->data.buf_ref = data; -@@ -259,7 +260,7 @@ void g_obex_packet_free(GObexPacket *pkt) - switch (pkt->data_policy) { - case G_OBEX_DATA_INHERIT: - case G_OBEX_DATA_COPY: -- g_free(pkt->data.buf); -+ free(pkt->data.buf); - break; - case G_OBEX_DATA_REF: - break; -diff --git a/obexd/src/obex.c b/obexd/src/obex.c -index 9f992ec18..3a68fd66c 100644 ---- a/obexd/src/obex.c -+++ b/obexd/src/obex.c -@@ -40,6 +40,7 @@ - #include "mimetype.h" - #include "service.h" - #include "transport.h" -+#include "src/shared/util.h" - - typedef struct { - uint8_t version; -@@ -145,7 +146,7 @@ static void os_reset_session(struct obex_session *os) - os->path = NULL; - } - if (os->apparam) { -- g_free(os->apparam); -+ free(os->apparam); - os->apparam = NULL; - os->apparam_len = 0; - } -@@ -594,7 +595,7 @@ static void parse_apparam(struct obex_session *os, GObexPacket *req) - if (!g_obex_header_get_bytes(hdr, &apparam, &len)) - return; - -- os->apparam = g_memdup(apparam, len); -+ os->apparam = util_memdup(apparam, len); - os->apparam_len = len; - DBG("APPARAM"); - } -diff --git a/plugins/neard.c b/plugins/neard.c -index e07b51106..a75527148 100644 ---- a/plugins/neard.c -+++ b/plugins/neard.c -@@ -30,6 +30,7 @@ - #include "src/eir.h" - #include "src/agent.h" - #include "src/btd.h" -+#include "src/shared/util.h" - - #define NEARD_NAME "org.neard" - #define NEARD_PATH "/" -@@ -71,7 +72,7 @@ static void free_oob_params(struct oob_params *params) - g_free(params->name); - g_free(params->hash); - g_free(params->randomizer); -- g_free(params->pin); -+ free(params->pin); - } - - static DBusMessage *error_reply(DBusMessage *msg, int error) -@@ -407,10 +408,10 @@ static int process_nokia_long (void *data, size_t size, uint8_t marker, - remote->name = g_strndup((char *)n->name, n->name_len); - - if (marker == 0x01) { -- remote->pin = g_memdup(n->authentication, 4); -+ remote->pin = util_memdup(n->authentication, 4); - remote->pin_len = 4; - } else if (marker == 0x02) { -- remote->pin = g_memdup(n->authentication, 16); -+ remote->pin = util_memdup(n->authentication, 16); - remote->pin_len = 16; - } - -@@ -439,7 +440,7 @@ static int process_nokia_short (void *data, size_t size, - if (n->name_len > 0) - remote->name = g_strndup((char *)n->name, n->name_len); - -- remote->pin = g_memdup(n->authentication, 4); -+ remote->pin = util_memdup(n->authentication, 4); - remote->pin_len = 4; - - return 0; -diff --git a/plugins/policy.c b/plugins/policy.c -index 051db82e1..48f5db7d3 100644 ---- a/plugins/policy.c -+++ b/plugins/policy.c -@@ -32,6 +32,7 @@ - #include "src/profile.h" - #include "src/btd.h" - #include "src/shared/timeout.h" -+#include "src/shared/util.h" - - #define CONTROL_CONNECT_TIMEOUT 2 - #define SOURCE_RETRY_TIMEOUT 2 -@@ -855,7 +856,7 @@ static int policy_init(void) - reconnect_attempts = default_attempts; - reconnect_intervals_len = sizeof(default_intervals) / - sizeof(*reconnect_intervals); -- reconnect_intervals = g_memdup(default_intervals, -+ reconnect_intervals = util_memdup(default_intervals, - sizeof(default_intervals)); - goto done; - } -@@ -886,7 +887,7 @@ static int policy_init(void) - g_clear_error(&gerr); - reconnect_intervals_len = sizeof(default_intervals) / - sizeof(*reconnect_intervals); -- reconnect_intervals = g_memdup(default_intervals, -+ reconnect_intervals = util_memdup(default_intervals, - sizeof(default_intervals)); - } - -@@ -919,7 +920,7 @@ static void policy_exit(void) - if (reconnect_uuids) - g_strfreev(reconnect_uuids); - -- g_free(reconnect_intervals); -+ free(reconnect_intervals); - - g_slist_free_full(reconnects, reconnect_destroy); - -diff --git a/profiles/audio/avctp.c b/profiles/audio/avctp.c -index 64d1a8504..6f64f162b 100644 ---- a/profiles/audio/avctp.c -+++ b/profiles/audio/avctp.c -@@ -40,6 +40,7 @@ - #include "src/log.h" - #include "src/error.h" - #include "src/shared/timeout.h" -+#include "src/shared/util.h" - - #include "avctp.h" - #include "avrcp.h" -@@ -760,7 +761,7 @@ static void control_req_destroy(void *data) - NULL, 0, req->user_data); - - done: -- g_free(req->operands); -+ free(req->operands); - g_free(req); - } - -@@ -776,7 +777,7 @@ static void browsing_req_destroy(void *data) - req->func(session, NULL, 0, req->user_data); - - done: -- g_free(req->operands); -+ free(req->operands); - g_free(req); - } - -@@ -1727,7 +1728,7 @@ static int avctp_send_req(struct avctp *session, uint8_t code, - req->subunit = subunit; - req->op = opcode; - req->func = func; -- req->operands = g_memdup(operands, operand_count); -+ req->operands = util_memdup(operands, operand_count); - req->operand_count = operand_count; - req->user_data = user_data; - -@@ -1765,7 +1766,7 @@ int avctp_send_browsing_req(struct avctp *session, - - req = g_new0(struct avctp_browsing_req, 1); - req->func = func; -- req->operands = g_memdup(operands, operand_count); -+ req->operands = util_memdup(operands, operand_count); - req->operand_count = operand_count; - req->user_data = user_data; - -diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c -index 7c280203c..d4e19ffc0 100644 ---- a/profiles/audio/avrcp.c -+++ b/profiles/audio/avrcp.c -@@ -1298,7 +1298,7 @@ static uint8_t avrcp_handle_get_current_player_value(struct avrcp *session, - * Save a copy of requested settings because we can override them - * while responding - */ -- settings = g_memdup(&pdu->params[1], pdu->params[0]); -+ settings = util_memdup(&pdu->params[1], pdu->params[0]); - len = 0; - - /* -@@ -1323,7 +1323,7 @@ static uint8_t avrcp_handle_get_current_player_value(struct avrcp *session, - pdu->params[++len] = val; - } - -- g_free(settings); -+ free(settings); - - if (len) { - pdu->params[0] = len / 2; -@@ -2801,7 +2801,7 @@ static gboolean avrcp_set_browsed_player_rsp(struct avctp *conn, - break; - } - -- folders[count] = g_memdup(&pdu->params[i], len); -+ folders[count] = util_memdup(&pdu->params[i], len); - i += len; - } - -@@ -2888,7 +2888,7 @@ static void avrcp_player_parse_features(struct avrcp_player *player, - { - struct media_player *mp = player->user_data; - -- player->features = g_memdup(features, 16); -+ player->features = util_memdup(features, 16); - - if (features[7] & 0x08) { - media_player_set_browsable(mp, true); -@@ -3622,7 +3622,7 @@ static void player_destroy(gpointer data) - g_slist_free(player->sessions); - g_free(player->path); - g_free(player->change_path); -- g_free(player->features); -+ free(player->features); - g_free(player); - } - -diff --git a/profiles/battery/bas.c b/profiles/battery/bas.c -index 3c6173b61..16ff22e19 100644 ---- a/profiles/battery/bas.c -+++ b/profiles/battery/bas.c -@@ -62,7 +62,7 @@ static void bas_free(struct bt_bas *bas) - { - bt_bas_detach(bas); - -- g_free(bas->primary); -+ free(bas->primary); - queue_destroy(bas->gatt_op, (void *) destroy_gatt_req); - free(bas); - } -@@ -75,7 +75,7 @@ struct bt_bas *bt_bas_new(void *primary) - bas->gatt_op = queue_new(); - - if (primary) -- bas->primary = g_memdup(primary, sizeof(*bas->primary)); -+ bas->primary = util_memdup(primary, sizeof(*bas->primary)); - - return bt_bas_ref(bas); - } -diff --git a/profiles/battery/battery.c b/profiles/battery/battery.c -index 176d127f6..02d024d92 100644 ---- a/profiles/battery/battery.c -+++ b/profiles/battery/battery.c -@@ -66,7 +66,7 @@ static void batt_free(struct batt *batt) - gatt_db_unref(batt->db); - bt_gatt_client_unref(batt->client); - btd_device_unref(batt->device); -- g_free (batt->initial_value); -+ free(batt->initial_value); - if (batt->battery) - btd_battery_unregister(batt->battery); - g_free(batt); -@@ -159,7 +159,7 @@ static void read_initial_battery_level_cb(bool success, - if (!length) - return; - -- batt->initial_value = g_memdup(value, length); -+ batt->initial_value = util_memdup(value, length); - - /* request notify */ - batt->batt_level_cb_id = -diff --git a/profiles/deviceinfo/dis.c b/profiles/deviceinfo/dis.c -index 87fa63306..f660179ed 100644 ---- a/profiles/deviceinfo/dis.c -+++ b/profiles/deviceinfo/dis.c -@@ -72,7 +72,7 @@ static void dis_free(struct bt_dis *dis) - { - bt_dis_detach(dis); - -- g_free(dis->primary); -+ free(dis->primary); - queue_destroy(dis->gatt_op, (void *) destroy_gatt_req); - g_free(dis); - } -@@ -143,7 +143,7 @@ struct bt_dis *bt_dis_new_primary(void *primary) - dis->gatt_op = queue_new(); - - if (primary) -- dis->primary = g_memdup(primary, sizeof(*dis->primary)); -+ dis->primary = util_memdup(primary, sizeof(*dis->primary)); - - return bt_dis_ref(dis); - } -diff --git a/profiles/input/hog-lib.c b/profiles/input/hog-lib.c -index 3bbe42370..d37caa1f1 100644 ---- a/profiles/input/hog-lib.c -+++ b/profiles/input/hog-lib.c -@@ -527,9 +527,9 @@ static void report_read_cb(guint8 status, const guint8 *pdu, guint16 len, - } - - if (report->value) -- g_free(report->value); -+ free(report->value); - -- report->value = g_memdup(pdu, len); -+ report->value = util_memdup(pdu, len); - report->len = len; - } - -@@ -1217,7 +1217,7 @@ static void report_free(void *data) - { - struct report *report = data; - -- g_free(report->value); -+ free(report->value); - g_free(report); - } - -@@ -1241,7 +1241,7 @@ static void hog_free(void *data) - bt_uhid_unref(hog->uhid); - g_slist_free_full(hog->reports, report_free); - g_free(hog->name); -- g_free(hog->primary); -+ free(hog->primary); - queue_destroy(hog->gatt_op, (void *) destroy_gatt_req); - if (hog->gatt_db) - gatt_db_unref(hog->gatt_db); -@@ -1609,7 +1609,7 @@ static void hog_attach_hog(struct bt_hog *hog, struct gatt_primary *primary) - struct bt_hog *instance; - - if (!hog->primary) { -- hog->primary = g_memdup(primary, sizeof(*primary)); -+ hog->primary = util_memdup(primary, sizeof(*primary)); - discover_char(hog, hog->attrib, primary->range.start, - primary->range.end, NULL, - char_discovered_cb, hog); -@@ -1623,7 +1623,7 @@ static void hog_attach_hog(struct bt_hog *hog, struct gatt_primary *primary) - if (!instance) - return; - -- instance->primary = g_memdup(primary, sizeof(*primary)); -+ instance->primary = util_memdup(primary, sizeof(*primary)); - find_included(instance, hog->attrib, primary->range.start, - primary->range.end, find_included_cb, instance); - -diff --git a/profiles/scanparam/scpp.c b/profiles/scanparam/scpp.c -index da38a6aaa..4be8b26cc 100644 ---- a/profiles/scanparam/scpp.c -+++ b/profiles/scanparam/scpp.c -@@ -91,7 +91,7 @@ static void scpp_free(struct bt_scpp *scan) - { - bt_scpp_detach(scan); - -- g_free(scan->primary); -+ free(scan->primary); - queue_destroy(scan->gatt_op, NULL); /* cleared in bt_scpp_detach */ - g_free(scan); - } -@@ -110,7 +110,7 @@ struct bt_scpp *bt_scpp_new(void *primary) - scan->gatt_op = queue_new(); - - if (primary) -- scan->primary = g_memdup(primary, sizeof(*scan->primary)); -+ scan->primary = util_memdup(primary, sizeof(*scan->primary)); - - return bt_scpp_ref(scan); - } -diff --git a/src/eir.c b/src/eir.c -index 0f5d14fcd..2f9ee036f 100644 ---- a/src/eir.c -+++ b/src/eir.c -@@ -53,9 +53,9 @@ void eir_data_free(struct eir_data *eir) - eir->services = NULL; - g_free(eir->name); - eir->name = NULL; -- g_free(eir->hash); -+ free(eir->hash); - eir->hash = NULL; -- g_free(eir->randomizer); -+ free(eir->randomizer); - eir->randomizer = NULL; - g_slist_free_full(eir->msd_list, g_free); - eir->msd_list = NULL; -@@ -323,13 +323,13 @@ void eir_parse(struct eir_data *eir, const uint8_t *eir_data, uint8_t eir_len) - case EIR_SSP_HASH: - if (data_len < 16) - break; -- eir->hash = g_memdup(data, 16); -+ eir->hash = util_memdup(data, 16); - break; - - case EIR_SSP_RANDOMIZER: - if (data_len < 16) - break; -- eir->randomizer = g_memdup(data, 16); -+ eir->randomizer = util_memdup(data, 16); - break; - - case EIR_DEVICE_ID: -diff --git a/tools/gatt-service.c b/tools/gatt-service.c -index 631c4f249..ed6b06f1e 100644 ---- a/tools/gatt-service.c -+++ b/tools/gatt-service.c -@@ -26,6 +26,7 @@ - #include "gdbus/gdbus.h" - - #include "src/error.h" -+#include "src/shared/util.h" - - #define GATT_MGR_IFACE "org.bluez.GattManager1" - #define GATT_SERVICE_IFACE "org.bluez.GattService1" -@@ -126,8 +127,8 @@ static gboolean desc_get_value(const GDBusPropertyTable *property, - - static void desc_write(struct descriptor *desc, const uint8_t *value, int len) - { -- g_free(desc->value); -- desc->value = g_memdup(value, len); -+ free(desc->value); -+ desc->value = util_memdup(value, len); - desc->vlen = len; - - g_dbus_emit_property_changed(connection, desc->path, -@@ -264,8 +265,8 @@ static gboolean chr_get_props(const GDBusPropertyTable *property, - - static void chr_write(struct characteristic *chr, const uint8_t *value, int len) - { -- g_free(chr->value); -- chr->value = g_memdup(value, len); -+ free(chr->value); -+ chr->value = util_memdup(value, len); - chr->vlen = len; - - g_dbus_emit_property_changed(connection, chr->path, GATT_CHR_IFACE, -@@ -388,7 +389,7 @@ static void chr_iface_destroy(gpointer user_data) - - g_free(chr->uuid); - g_free(chr->service); -- g_free(chr->value); -+ free(chr->value); - g_free(chr->path); - g_free(chr); - } -@@ -398,7 +399,7 @@ static void desc_iface_destroy(gpointer user_data) - struct descriptor *desc = user_data; - - g_free(desc->uuid); -- g_free(desc->value); -+ free(desc->value); - g_free(desc->path); - g_free(desc); - } -@@ -592,7 +593,7 @@ static gboolean register_characteristic(const char *chr_uuid, - - chr = g_new0(struct characteristic, 1); - chr->uuid = g_strdup(chr_uuid); -- chr->value = g_memdup(value, vlen); -+ chr->value = util_memdup(value, vlen); - chr->vlen = vlen; - chr->props = props; - chr->service = g_strdup(service_path); -diff --git a/tools/mesh-gatt/gatt.c b/tools/mesh-gatt/gatt.c -index c8a8123fb..ab9743cd1 100644 ---- a/tools/mesh-gatt/gatt.c -+++ b/tools/mesh-gatt/gatt.c -@@ -24,6 +24,7 @@ - - #include "src/shared/io.h" - #include "src/shared/shell.h" -+#include "src/shared/util.h" - #include "gdbus/gdbus.h" - #include "lib/bluetooth.h" - #include "lib/uuid.h" -@@ -86,7 +87,7 @@ static void write_data_free(void *user_data) - { - struct write_data *data = user_data; - -- g_free(data->gatt_data); -+ free(data->gatt_data); - free(data); - } - -@@ -338,7 +339,7 @@ bool mesh_gatt_write(GDBusProxy *proxy, uint8_t *buf, uint16_t len, - /* TODO: should keep in queue in case we need to cancel write? */ - - data->gatt_len = len; -- data->gatt_data = g_memdup(buf, len); -+ data->gatt_data = util_memdup(buf, len); - data->gatt_data[0] &= GATT_TYPE_MASK; - data->iov.iov_base = data->gatt_data; - data->iov.iov_len = len; -diff --git a/unit/test-avctp.c b/unit/test-avctp.c -index fa7db59c8..25fd3abc2 100644 ---- a/unit/test-avctp.c -+++ b/unit/test-avctp.c -@@ -53,7 +53,7 @@ struct context { - #define raw_pdu(args...) \ - { \ - .valid = true, \ -- .data = g_memdup(data(args), sizeof(data(args))), \ -+ .data = util_memdup(data(args), sizeof(data(args))), \ - .size = sizeof(data(args)), \ - } - -@@ -64,7 +64,7 @@ struct context { - }; \ - static struct test_data data; \ - data.test_name = g_strdup(name); \ -- data.pdu_list = g_memdup(pdus, sizeof(pdus)); \ -+ data.pdu_list = util_memdup(pdus, sizeof(pdus)); \ - tester_add(name, &data, NULL, function, NULL); \ - } while (0) - -diff --git a/unit/test-avdtp.c b/unit/test-avdtp.c -index 4e8a68c6b..2e49def43 100644 ---- a/unit/test-avdtp.c -+++ b/unit/test-avdtp.c -@@ -48,7 +48,7 @@ struct test_data { - #define raw_pdu(args...) \ - { \ - .valid = true, \ -- .data = g_memdup(data(args), sizeof(data(args))), \ -+ .data = util_memdup(data(args), sizeof(data(args))), \ - .size = sizeof(data(args)), \ - } - -@@ -56,7 +56,7 @@ struct test_data { - { \ - .valid = true, \ - .fragmented = true, \ -- .data = g_memdup(data(args), sizeof(data(args))), \ -+ .data = util_memdup(data(args), sizeof(data(args))), \ - .size = sizeof(data(args)), \ - } - -@@ -67,7 +67,7 @@ struct test_data { - }; \ - static struct test_data data; \ - data.test_name = g_strdup(name); \ -- data.pdu_list = g_memdup(pdus, sizeof(pdus)); \ -+ data.pdu_list = util_memdup(pdus, sizeof(pdus)); \ - tester_add(name, &data, NULL, function, NULL); \ - } while (0) - -diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c -index 34a70377d..b637a8a1b 100644 ---- a/unit/test-avrcp.c -+++ b/unit/test-avrcp.c -@@ -61,7 +61,7 @@ struct context { - #define raw_pdu(args...) \ - { \ - .valid = true, \ -- .data = g_memdup(data(args), sizeof(data(args))), \ -+ .data = util_memdup(data(args), sizeof(data(args))), \ - .size = sizeof(data(args)), \ - } - -@@ -69,7 +69,7 @@ struct context { - { \ - .valid = true, \ - .browse = true, \ -- .data = g_memdup(data(args), sizeof(data(args))), \ -+ .data = util_memdup(data(args), sizeof(data(args))), \ - .size = sizeof(data(args)), \ - } - -@@ -77,7 +77,7 @@ struct context { - { \ - .valid = true, \ - .fragmented = true, \ -- .data = g_memdup(data(args), sizeof(data(args))), \ -+ .data = util_memdup(data(args), sizeof(data(args))), \ - .size = sizeof(data(args)), \ - } - -@@ -85,7 +85,7 @@ struct context { - { \ - .valid = true, \ - .continuing = true, \ -- .data = g_memdup(data(args), sizeof(data(args))), \ -+ .data = util_memdup(data(args), sizeof(data(args))), \ - .size = sizeof(data(args)), \ - } - -@@ -96,7 +96,7 @@ struct context { - }; \ - static struct test_data data; \ - data.test_name = g_strdup(name); \ -- data.pdu_list = g_memdup(pdus, sizeof(pdus)); \ -+ data.pdu_list = util_memdup(pdus, sizeof(pdus)); \ - tester_add(name, &data, NULL, function, NULL); \ - } while (0) - -diff --git a/unit/test-gatt.c b/unit/test-gatt.c -index 6a47268e6..f92d860c4 100644 ---- a/unit/test-gatt.c -+++ b/unit/test-gatt.c -@@ -73,7 +73,7 @@ struct context { - #define raw_pdu(args...) \ - { \ - .valid = true, \ -- .data = g_memdup(data(args), sizeof(data(args))), \ -+ .data = util_memdup(data(args), sizeof(data(args))), \ - .size = sizeof(data(args)), \ - } - -@@ -94,7 +94,7 @@ struct context { - data.uuid = bt_uuid; \ - data.step = test_step; \ - data.source_db = db; \ -- data.pdu_list = g_memdup(pdus, sizeof(pdus)); \ -+ data.pdu_list = util_memdup(pdus, sizeof(pdus)); \ - tester_add(name, &data, NULL, function, NULL); \ - } while (0) - -diff --git a/unit/test-hfp.c b/unit/test-hfp.c -index f504724d7..b4af99d53 100644 ---- a/unit/test-hfp.c -+++ b/unit/test-hfp.c -@@ -17,6 +17,7 @@ - #include - #include "src/shared/hfp.h" - #include "src/shared/tester.h" -+#include "src/shared/util.h" - - struct context { - guint watch_id; -@@ -50,7 +51,7 @@ struct test_data { - #define raw_pdu(args...) \ - { \ - .valid = true, \ -- .data = g_memdup(data(args), sizeof(data(args))), \ -+ .data = util_memdup(data(args), sizeof(data(args))), \ - .size = sizeof(data(args)), \ - } - -@@ -62,7 +63,7 @@ struct test_data { - #define type_pdu(cmd_type, args...) \ - { \ - .valid = true, \ -- .data = g_memdup(data(args), sizeof(data(args))), \ -+ .data = util_memdup(data(args), sizeof(data(args))), \ - .size = sizeof(data(args)), \ - .type = cmd_type, \ - } -@@ -70,7 +71,7 @@ struct test_data { - #define frg_pdu(args...) \ - { \ - .valid = true, \ -- .data = g_memdup(data(args), sizeof(data(args))), \ -+ .data = util_memdup(data(args), sizeof(data(args))), \ - .size = sizeof(data(args)), \ - .fragmented = true, \ - } -@@ -82,7 +83,7 @@ struct test_data { - }; \ - static struct test_data data; \ - data.test_name = g_strdup(name); \ -- data.pdu_list = g_memdup(pdus, sizeof(pdus)); \ -+ data.pdu_list = util_memdup(pdus, sizeof(pdus)); \ - data.result_func = result_function; \ - tester_add(name, &data, NULL, function, NULL); \ - data.test_handler = test_handler; \ -@@ -96,7 +97,7 @@ struct test_data { - }; \ - static struct test_data data; \ - data.test_name = g_strdup(name); \ -- data.pdu_list = g_memdup(pdus, sizeof(pdus)); \ -+ data.pdu_list = util_memdup(pdus, sizeof(pdus)); \ - data.hf_result_func = result_func; \ - data.response_func = response_function; \ - tester_add(name, &data, NULL, function, NULL); \ -diff --git a/unit/test-hog.c b/unit/test-hog.c -index 116a5cb07..067497de4 100644 ---- a/unit/test-hog.c -+++ b/unit/test-hog.c -@@ -59,24 +59,24 @@ struct context { - #define raw_pdu(args...) \ - { \ - .valid = true, \ -- .data = g_memdup(data(args), sizeof(data(args))), \ -+ .data = util_memdup(data(args), sizeof(data(args))), \ - .size = sizeof(data(args)), \ - } - --#define false_pdu() \ --{ \ -- .valid = false, \ -+#define false_pdu() \ -+{ \ -+ .valid = false, \ - } - --#define define_test(name, function, args...) \ -- do { \ -- const struct test_pdu pdus[] = { \ -- args, { } \ -- }; \ -- static struct test_data data; \ -- data.test_name = g_strdup(name); \ -- data.pdu_list = g_memdup(pdus, sizeof(pdus)); \ -- tester_add(name, &data, NULL, function, NULL); \ -+#define define_test(name, function, args...) \ -+ do { \ -+ const struct test_pdu pdus[] = { \ -+ args, { } \ -+ }; \ -+ static struct test_data data; \ -+ data.test_name = g_strdup(name); \ -+ data.pdu_list = util_memdup(pdus, sizeof(pdus));\ -+ tester_add(name, &data, NULL, function, NULL); \ - } while (0) - - static gboolean context_quit(gpointer user_data) -diff --git a/unit/test-sdp.c b/unit/test-sdp.c -index 8f95fcb71..5c04a71eb 100644 ---- a/unit/test-sdp.c -+++ b/unit/test-sdp.c -@@ -47,14 +47,16 @@ struct test_data { - #define raw_pdu(args...) \ - { \ - .valid = true, \ -- .raw_data = g_memdup(raw_data(args), sizeof(raw_data(args))), \ -+ .raw_data = util_memdup(raw_data(args), \ -+ sizeof(raw_data(args))), \ - .raw_size = sizeof(raw_data(args)), \ - } - - #define raw_pdu_cont(cont, args...) \ - { \ - .valid = true, \ -- .raw_data = g_memdup(raw_data(args), sizeof(raw_data(args))), \ -+ .raw_data = util_memdup(raw_data(args), \ -+ sizeof(raw_data(args))), \ - .raw_size = sizeof(raw_data(args)), \ - .cont_len = cont, \ - } -@@ -66,7 +68,7 @@ struct test_data { - }; \ - static struct test_data data; \ - data.mtu = _mtu; \ -- data.pdu_list = g_memdup(pdus, sizeof(pdus)); \ -+ data.pdu_list = util_memdup(pdus, sizeof(pdus)); \ - tester_add(name, &data, NULL, test_sdp, NULL); \ - } while (0) - -@@ -92,7 +94,7 @@ struct test_data_de { - #define define_test_de_attr(name, input, exp) \ - do { \ - static struct test_data_de data; \ -- data.input_data = g_memdup(input, sizeof(input)); \ -+ data.input_data = util_memdup(input, sizeof(input)); \ - data.input_size = sizeof(input); \ - data.expected = exp; \ - tester_add("/sdp/DE/ATTR/" name, &data, NULL, \ -diff --git a/unit/test-uhid.c b/unit/test-uhid.c -index 001d39a3d..8a8eef855 100644 ---- a/unit/test-uhid.c -+++ b/unit/test-uhid.c -@@ -61,7 +61,7 @@ struct context { - }; \ - static struct test_data data; \ - data.test_name = g_strdup(name); \ -- data.pdu_list = g_memdup(pdus, sizeof(pdus)); \ -+ data.pdu_list = util_memdup(pdus, sizeof(pdus)); \ - tester_add(name, &data, NULL, function, NULL); \ - } while (0) - --- -2.17.1 - diff --git a/package/bluez5_utils/0005-build-Fix-errors-with-glibc-2-25.patch b/package/bluez5_utils/0005-build-Fix-errors-with-glibc-2-25.patch deleted file mode 100644 index 13033da7b2..0000000000 --- a/package/bluez5_utils/0005-build-Fix-errors-with-glibc-2-25.patch +++ /dev/null @@ -1,312 +0,0 @@ -From fb57ad9b9d107856e5f1c8135da04ffa2f7a11ac Mon Sep 17 00:00:00 2001 -From: Fabrice Fontaine -Date: Mon, 14 Feb 2022 21:17:39 +0100 -Subject: build: Fix errors with glibc < 2.25 - -getrandom and sys/random.h are only available since glibc 2.25: -https://www.gnu.org/software/gnulib/manual/html_node/sys_002frandom_002eh.html -resulting in the following build failures since version 5.63 and -https://git.kernel.org/pub/scm/bluetooth/bluez.git/log/?qt=grep&q=getrandom: - -plugins/autopair.c:20:24: fatal error: sys/random.h: No such file or directory - #include - ^ - -To fix this build failure, add util_getrandom and a fallback (borrowed -from pipewire and licensed under MIT): -https://gitlab.freedesktop.org/pipewire/pipewire/-/blob/master/src/pipewire/utils.c - -Fixes: - - http://autobuild.buildroot.org/results/6b8870d12e0804d6154230a7322c49416c1dc0e2 - -[Retrieved from: -https://git.kernel.org/pub/scm/bluetooth/bluez.git/commit/?id=fb57ad9b9d107856e5f1c8135da04ffa2f7a11ac] -Signed-off-by: Fabrice Fontaine ---- - configure.ac | 4 +++- - emulator/le.c | 3 +-- - emulator/phy.c | 3 +-- - peripheral/main.c | 4 ++-- - plugins/autopair.c | 4 ++-- - profiles/health/hdp.c | 4 ++-- - profiles/health/mcap.c | 6 +++--- - src/shared/util.c | 25 +++++++++++++++++++++++++ - src/shared/util.h | 2 ++ - tools/btgatt-server.c | 3 +-- - 10 files changed, 42 insertions(+), 16 deletions(-) - -diff --git a/configure.ac b/configure.ac -index 07d068a4d..441bd5f29 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -54,6 +54,8 @@ AC_ARG_ENABLE(threads, AS_HELP_STRING([--enable-threads], - - AC_CHECK_FUNCS(explicit_bzero) - -+AC_CHECK_FUNCS(getrandom) -+ - AC_CHECK_FUNCS(rawmemchr) - - AC_CHECK_FUNC(signalfd, dummy=yes, -@@ -68,7 +70,7 @@ AC_CHECK_LIB(pthread, pthread_create, dummy=yes, - AC_CHECK_LIB(dl, dlopen, dummy=yes, - AC_MSG_ERROR(dynamic linking loader is required)) - --AC_CHECK_HEADERS(linux/types.h linux/if_alg.h linux/uinput.h linux/uhid.h) -+AC_CHECK_HEADERS(linux/types.h linux/if_alg.h linux/uinput.h linux/uhid.h sys/random.h) - - PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.28, dummy=yes, - AC_MSG_ERROR(GLib >= 2.28 is required)) -diff --git a/emulator/le.c b/emulator/le.c -index f8f313f2c..7656a657c 100644 ---- a/emulator/le.c -+++ b/emulator/le.c -@@ -20,7 +20,6 @@ - #include - #include - #include --#include - #include - - #include "lib/bluetooth.h" -@@ -509,7 +508,7 @@ static unsigned int get_adv_delay(void) - /* The advertising delay is a pseudo-random value with a range - * of 0 ms to 10 ms generated for each advertising event. - */ -- if (getrandom(&val, sizeof(val), 0) < 0) { -+ if (util_getrandom(&val, sizeof(val), 0) < 0) { - /* If it fails to get the random number, use a static value */ - val = 5; - } -diff --git a/emulator/phy.c b/emulator/phy.c -index 44cace438..7de85fb05 100644 ---- a/emulator/phy.c -+++ b/emulator/phy.c -@@ -19,7 +19,6 @@ - #include - #include - #include --#include - #include - #include - #include -@@ -174,7 +173,7 @@ struct bt_phy *bt_phy_new(void) - mainloop_add_fd(phy->rx_fd, EPOLLIN, phy_rx_callback, phy, NULL); - - if (!get_random_bytes(&phy->id, sizeof(phy->id))) { -- if (getrandom(&phy->id, sizeof(phy->id), 0) < 0) { -+ if (util_getrandom(&phy->id, sizeof(phy->id), 0) < 0) { - mainloop_remove_fd(phy->rx_fd); - close(phy->tx_fd); - close(phy->rx_fd); -diff --git a/peripheral/main.c b/peripheral/main.c -index 91adb45fc..b82d7caf6 100644 ---- a/peripheral/main.c -+++ b/peripheral/main.c -@@ -25,13 +25,13 @@ - #include - #include - #include --#include - - #ifndef WAIT_ANY - #define WAIT_ANY (-1) - #endif - - #include "src/shared/mainloop.h" -+#include "src/shared/util.h" - #include "peripheral/efivars.h" - #include "peripheral/attach.h" - #include "peripheral/gap.h" -@@ -192,7 +192,7 @@ int main(int argc, char *argv[]) - addr, 6) < 0) { - printf("Generating new persistent static address\n"); - -- if (getrandom(addr, sizeof(addr), 0) < 0) { -+ if (util_getrandom(addr, sizeof(addr), 0) < 0) { - perror("Failed to get random static address"); - return EXIT_FAILURE; - } -diff --git a/plugins/autopair.c b/plugins/autopair.c -index a75ecebe4..0b09e893f 100644 ---- a/plugins/autopair.c -+++ b/plugins/autopair.c -@@ -17,7 +17,6 @@ - #include - #include - #include --#include - - #include - -@@ -29,6 +28,7 @@ - #include "src/device.h" - #include "src/log.h" - #include "src/storage.h" -+#include "src/shared/util.h" - - /* - * Plugin to handle automatic pairing of devices with reduced user -@@ -131,7 +131,7 @@ static ssize_t autopair_pincb(struct btd_adapter *adapter, - if (attempt >= 4) - return 0; - -- if (getrandom(&val, sizeof(val), 0) < 0) { -+ if (util_getrandom(&val, sizeof(val), 0) < 0) { - error("Failed to get a random pincode"); - return 0; - } -diff --git a/profiles/health/hdp.c b/profiles/health/hdp.c -index 9d9d1e824..b6590cd3a 100644 ---- a/profiles/health/hdp.c -+++ b/profiles/health/hdp.c -@@ -16,7 +16,6 @@ - #include - #include - #include --#include - - #include - -@@ -33,6 +32,7 @@ - #include "src/device.h" - #include "src/sdpd.h" - #include "src/shared/timeout.h" -+#include "src/shared/util.h" - #include "btio/btio.h" - - #include "hdp_types.h" -@@ -1490,7 +1490,7 @@ static void *generate_echo_packet(void) - if (!buf) - return NULL; - -- if (getrandom(buf, HDP_ECHO_LEN, 0) < 0) { -+ if (util_getrandom(buf, HDP_ECHO_LEN, 0) < 0) { - g_free(buf); - return NULL; - } -diff --git a/profiles/health/mcap.c b/profiles/health/mcap.c -index aad0a08a3..5d2bac3d9 100644 ---- a/profiles/health/mcap.c -+++ b/profiles/health/mcap.c -@@ -19,7 +19,6 @@ - #include - #include - #include --#include - - #include - -@@ -28,6 +27,7 @@ - #include "btio/btio.h" - #include "src/log.h" - #include "src/shared/timeout.h" -+#include "src/shared/util.h" - - #include "mcap.h" - -@@ -1905,7 +1905,7 @@ gboolean mcap_create_mcl(struct mcap_instance *mi, - mcl->state = MCL_IDLE; - bacpy(&mcl->addr, addr); - set_default_cb(mcl); -- if (getrandom(&val, sizeof(val), 0) < 0) { -+ if (util_getrandom(&val, sizeof(val), 0) < 0) { - mcap_instance_unref(mcl->mi); - g_free(mcl); - return FALSE; -@@ -2049,7 +2049,7 @@ static void connect_mcl_event_cb(GIOChannel *chan, GError *gerr, - mcl->mi = mcap_instance_ref(mi); - bacpy(&mcl->addr, &dst); - set_default_cb(mcl); -- if (getrandom(&val, sizeof(val), 0) < 0) { -+ if (util_getrandom(&val, sizeof(val), 0) < 0) { - mcap_instance_unref(mcl->mi); - g_free(mcl); - goto drop; -diff --git a/src/shared/util.c b/src/shared/util.c -index 6e1c83057..33196bf8b 100644 ---- a/src/shared/util.c -+++ b/src/shared/util.c -@@ -13,6 +13,7 @@ - #endif - - #define _GNU_SOURCE -+#include - #include - #include - #include -@@ -23,6 +24,10 @@ - #include - #include - -+#ifdef HAVE_SYS_RANDOM_H -+#include -+#endif -+ - #include "src/shared/util.h" - - void *util_malloc(size_t size) -@@ -138,6 +143,26 @@ unsigned char util_get_dt(const char *parent, const char *name) - return DT_UNKNOWN; - } - -+/* Helper for getting a random in case getrandom unavailable (glibc < 2.25) */ -+ssize_t util_getrandom(void *buf, size_t buflen, unsigned int flags) -+{ -+#ifdef HAVE_GETRANDOM -+ return getrandom(buf, buflen, flags); -+#else -+ int fd; -+ ssize_t bytes; -+ -+ fd = open("/dev/urandom", O_CLOEXEC); -+ if (fd < 0) -+ return -1; -+ -+ bytes = read(fd, buf, buflen); -+ close(fd); -+ -+ return bytes; -+#endif -+} -+ - /* Helpers for bitfield operations */ - - /* Find unique id in range from 1 to max but no bigger than 64. */ -diff --git a/src/shared/util.h b/src/shared/util.h -index 8ef6132c4..c01eccf8a 100644 ---- a/src/shared/util.h -+++ b/src/shared/util.h -@@ -103,6 +103,8 @@ void util_hexdump(const char dir, const unsigned char *buf, size_t len, - - unsigned char util_get_dt(const char *parent, const char *name); - -+ssize_t util_getrandom(void *buf, size_t buflen, unsigned int flags); -+ - uint8_t util_get_uid(uint64_t *bitmap, uint8_t max); - void util_clear_uid(uint64_t *bitmap, uint8_t id); - -diff --git a/tools/btgatt-server.c b/tools/btgatt-server.c -index 15d49a464..4a5d2b720 100644 ---- a/tools/btgatt-server.c -+++ b/tools/btgatt-server.c -@@ -20,7 +20,6 @@ - #include - #include - #include --#include - - #include "lib/bluetooth.h" - #include "lib/hci.h" -@@ -287,7 +286,7 @@ static bool hr_msrmt_cb(void *user_data) - uint32_t cur_ee; - uint32_t val; - -- if (getrandom(&val, sizeof(val), 0) < 0) -+ if (util_getrandom(&val, sizeof(val), 0) < 0) - return false; - - pdu[0] = 0x06; --- -cgit - diff --git a/package/bluez5_utils/0006-src-shared-util.h-include-sys-types.h.patch b/package/bluez5_utils/0006-src-shared-util.h-include-sys-types.h.patch deleted file mode 100644 index 8a5bd64d43..0000000000 --- a/package/bluez5_utils/0006-src-shared-util.h-include-sys-types.h.patch +++ /dev/null @@ -1,39 +0,0 @@ -From 1d21878d84f16e28e16c61b36799a62e22732d97 Mon Sep 17 00:00:00 2001 -From: Fabrice Fontaine -Date: Thu, 24 Feb 2022 18:19:33 +0100 -Subject: [PATCH] src/shared/util.h: include sys/types.h - -Include sys/types.h to avoid the following build failure on musl raised -since commit fb57ad9b9d107856e5f1c8135da04ffa2f7a11ac: - -In file included from src/shared/queue.c:15: -./src/shared/util.h:106:1: error: unknown type name 'ssize_t'; did you mean 'size_t'? - 106 | ssize_t util_getrandom(void *buf, size_t buflen, unsigned int flags); - | ^~~~~~~ - | size_t - -Fixes: - - http://autobuild.buildroot.org/results/83eaeb3863040645409f5787fdbdde79385c5257 - -Signed-off-by: Fabrice Fontaine -[Upstream status: -https://patchwork.kernel.org/project/bluetooth/patch/20220224173104.479809-1-fontaine.fabrice@gmail.com] ---- - src/shared/util.h | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/src/shared/util.h b/src/shared/util.h -index c01eccf8a..554481e1e 100644 ---- a/src/shared/util.h -+++ b/src/shared/util.h -@@ -14,6 +14,7 @@ - #include - #include - #include -+#include - - #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) - #define BIT(n) (1 << (n)) --- -2.34.1 - diff --git a/package/bluez5_utils/bluez5_utils.hash b/package/bluez5_utils/bluez5_utils.hash index a8f5399fa6..0324dd2d77 100644 --- a/package/bluez5_utils/bluez5_utils.hash +++ b/package/bluez5_utils/bluez5_utils.hash @@ -1,5 +1,5 @@ # From https://www.kernel.org/pub/linux/bluetooth/sha256sums.asc: -sha256 9349e11e8160bb3d720835d271250d8a7424d3690f5289e6db6fe07cc66c6d76 bluez-5.63.tar.xz +sha256 ae437e65b6b3070c198bc5b0109fe9cdeb9eaa387380e2072f9de65fe8a1de34 bluez-5.64.tar.xz # Locally computed sha256 b499eddebda05a8859e32b820a64577d91f1de2b52efa2a1575a2cb4000bc259 COPYING sha256 ec60b993835e2c6b79e6d9226345f4e614e686eb57dc13b6420c15a33a8996e5 COPYING.LIB diff --git a/package/bluez5_utils/bluez5_utils.mk b/package/bluez5_utils/bluez5_utils.mk index 3d76cfb7dc..8e2c657899 100644 --- a/package/bluez5_utils/bluez5_utils.mk +++ b/package/bluez5_utils/bluez5_utils.mk @@ -5,7 +5,7 @@ ################################################################################ # Keep the version and patches in sync with bluez5_utils-headers -BLUEZ5_UTILS_VERSION = 5.63 +BLUEZ5_UTILS_VERSION = 5.64 BLUEZ5_UTILS_SOURCE = bluez-$(BLUEZ5_UTILS_VERSION).tar.xz BLUEZ5_UTILS_SITE = $(BR2_KERNEL_MIRROR)/linux/bluetooth BLUEZ5_UTILS_INSTALL_STAGING = YES @@ -13,8 +13,6 @@ BLUEZ5_UTILS_LICENSE = GPL-2.0+, LGPL-2.1+ BLUEZ5_UTILS_LICENSE_FILES = COPYING COPYING.LIB BLUEZ5_UTILS_CPE_ID_VENDOR = bluez BLUEZ5_UTILS_CPE_ID_PRODUCT = bluez -# We're patching Makefile.am and configure.ac -BLUEZ5_UTILS_AUTORECONF = YES BLUEZ5_UTILS_DEPENDENCIES = \ $(if $(BR2_PACKAGE_BLUEZ5_UTILS_HEADERS),bluez5_utils-headers) \