From 3f3b54f33fbb1acf2124cc0fa8929047a2aec1fa Mon Sep 17 00:00:00 2001 From: dh79pyun Date: Thu, 23 Dec 2021 08:43:11 +0900 Subject: [PATCH] Use g_memdup2 for glib 2.70 upgrade Change-Id: I026932523b303f0e21354baaf1301e7bbea144d9 Signed-off-by: dh79pyun --- .../Use-g_memdup2-for-glib-2.70-upgrade.patch | 736 +++++++++++++++++++++ packaging/bluez.spec | 2 + 2 files changed, 738 insertions(+) create mode 100644 packaging/Use-g_memdup2-for-glib-2.70-upgrade.patch diff --git a/packaging/Use-g_memdup2-for-glib-2.70-upgrade.patch b/packaging/Use-g_memdup2-for-glib-2.70-upgrade.patch new file mode 100644 index 0000000..cd11673 --- /dev/null +++ b/packaging/Use-g_memdup2-for-glib-2.70-upgrade.patch @@ -0,0 +1,736 @@ +From 6d75c370506f95aa917d77d745a60bad3693b4cd Mon Sep 17 00:00:00 2001 +From: dh79pyun +Date: Thu, 23 Dec 2021 08:29:10 +0900 +Subject: [PATCH] Use g_memdup2 for glib 2.70 upgrade + +Change-Id: Ida1647498a7f615d183d2111e4acef0d4840c4ed +Signed-off-by: dh79pyun +--- + attrib/gatt.c | 6 +++--- + client/gatt.c | 2 +- + gobex/gobex-header.c | 4 ++-- + gobex/gobex-packet.c | 2 +- + obexd/src/obex.c | 2 +- + plugins/neard.c | 6 +++--- + plugins/policy.c | 4 ++-- + profiles/alert/server.c | 2 +- + profiles/audio/avctp.c | 4 ++-- + profiles/audio/avrcp.c | 6 +++--- + profiles/battery/bas.c | 2 +- + profiles/battery/battery.c | 2 +- + profiles/cyclingspeed/cyclingspeed.c | 2 +- + profiles/deviceinfo/dis.c | 2 +- + profiles/input/hog-lib.c | 6 +++--- + profiles/scanparam/scpp.c | 2 +- + profiles/tds/tds.c | 2 +- + src/adapter.c | 4 ++-- + src/attrib-server.c | 2 +- + src/device.c | 4 ++-- + src/eir.c | 6 +++--- + tools/gatt-service.c | 6 +++--- + tools/mesh-gatt/gatt.c | 2 +- + unit/test-avctp.c | 4 ++-- + unit/test-avdtp.c | 6 +++--- + unit/test-avrcp.c | 10 +++++----- + unit/test-gatt.c | 4 ++-- + unit/test-hfp.c | 10 +++++----- + unit/test-hog.c | 4 ++-- + unit/test-sdp.c | 8 ++++---- + unit/test-uhid.c | 2 +- + 31 files changed, 64 insertions(+), 64 deletions(-) + +diff --git a/attrib/gatt.c b/attrib/gatt.c +index 72457cee..e06c9dc3 100755 +--- a/attrib/gatt.c ++++ b/attrib/gatt.c +@@ -720,7 +720,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 = g_memdup2(uuid, sizeof(bt_uuid_t)); + + dc->id = g_attrib_send(attrib, 0, buf, plen, char_discovered_cb, + discover_char_ref(dc), discover_char_unref); +@@ -1027,7 +1027,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 = g_memdup2(value, vlen); + long_write->vlen = vlen; + + return prepare_write(long_write); +@@ -1193,7 +1193,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 = g_memdup2(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 c48e94e7..44d5bb69 100755 +--- a/client/gatt.c ++++ b/client/gatt.c +@@ -802,7 +802,7 @@ static uint8_t *str2bytearray(char *arg, size_t *val_len) + + *val_len = i; + +- return g_memdup(value, i); ++ return g_memdup2(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 c6634c7b..9afd7852 100755 +--- a/gobex/gobex-header.c ++++ b/gobex/gobex-header.c +@@ -235,7 +235,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 = g_memdup2(ptr, header->vlen); + break; + case G_OBEX_DATA_REF: + header->extdata = TRUE; +@@ -434,7 +434,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 = g_memdup2(data, len); + + return header; + } +diff --git a/gobex/gobex-packet.c b/gobex/gobex-packet.c +index a89f5b6d..57f6399e 100755 +--- a/gobex/gobex-packet.c ++++ b/gobex/gobex-packet.c +@@ -214,7 +214,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 = g_memdup2(data, len); + break; + case G_OBEX_DATA_REF: + pkt->data.buf_ref = data; +diff --git a/obexd/src/obex.c b/obexd/src/obex.c +index cead193c..e302fd99 100644 +--- a/obexd/src/obex.c ++++ b/obexd/src/obex.c +@@ -628,7 +628,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 = g_memdup2(apparam, len); + os->apparam_len = len; + DBG("APPARAM"); + } +diff --git a/plugins/neard.c b/plugins/neard.c +index 51e276e4..74804356 100755 +--- a/plugins/neard.c ++++ b/plugins/neard.c +@@ -426,10 +426,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 = g_memdup2(n->authentication, 4); + remote->pin_len = 4; + } else if (marker == 0x02) { +- remote->pin = g_memdup(n->authentication, 16); ++ remote->pin = g_memdup2(n->authentication, 16); + remote->pin_len = 16; + } + +@@ -458,7 +458,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 = g_memdup2(n->authentication, 4); + remote->pin_len = 4; + + return 0; +diff --git a/plugins/policy.c b/plugins/policy.c +index 0eca6b4d..8158f2fe 100755 +--- a/plugins/policy.c ++++ b/plugins/policy.c +@@ -862,7 +862,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 = g_memdup2(default_intervals, + sizeof(default_intervals)); + goto done; + } +@@ -893,7 +893,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 = g_memdup2(default_intervals, + sizeof(default_intervals)); + } + +diff --git a/profiles/alert/server.c b/profiles/alert/server.c +index 2f6e3cde..5f83104e 100755 +--- a/profiles/alert/server.c ++++ b/profiles/alert/server.c +@@ -460,7 +460,7 @@ static void notify_devices(struct alert_adapter *al_adapter, + notify_data = g_new0(struct notify_data, 1); + notify_data->al_adapter = al_adapter; + notify_data->type = type; +- notify_data->value = g_memdup(value, len); ++ notify_data->value = g_memdup2(value, len); + notify_data->len = len; + + btd_adapter_for_each_device(al_adapter->adapter, filter_devices_notify, +diff --git a/profiles/audio/avctp.c b/profiles/audio/avctp.c +index e194bf52..c35ebb28 100644 +--- a/profiles/audio/avctp.c ++++ b/profiles/audio/avctp.c +@@ -1854,7 +1854,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 = g_memdup2(operands, operand_count); + req->operand_count = operand_count; + req->user_data = user_data; + +@@ -1892,7 +1892,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 = g_memdup2(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 c22b0aa9..1c8bae03 100644 +--- a/profiles/audio/avrcp.c ++++ b/profiles/audio/avrcp.c +@@ -1400,7 +1400,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 = g_memdup2(&pdu->params[1], pdu->params[0]); + len = 0; + + /* +@@ -2969,7 +2969,7 @@ static gboolean avrcp_set_browsed_player_rsp(struct avctp *conn, + break; + } + +- folders[count] = g_memdup(&pdu->params[i], len); ++ folders[count] = g_memdup2(&pdu->params[i], len); + i += len; + } + +@@ -3067,7 +3067,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 = g_memdup2(features, 16); + + if (features[7] & 0x08) { + media_player_set_browsable(mp, true); +diff --git a/profiles/battery/bas.c b/profiles/battery/bas.c +index de369fd3..f7721502 100755 +--- a/profiles/battery/bas.c ++++ b/profiles/battery/bas.c +@@ -88,7 +88,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 = g_memdup2(primary, sizeof(*bas->primary)); + + return bt_bas_ref(bas); + } +diff --git a/profiles/battery/battery.c b/profiles/battery/battery.c +index c9a1af4b..fc1f3953 100644 +--- a/profiles/battery/battery.c ++++ b/profiles/battery/battery.c +@@ -184,7 +184,7 @@ static void read_initial_battery_level_cb(bool success, + if (!length) + return; + +- batt->initial_value = g_memdup(value, length); ++ batt->initial_value = g_memdup2(value, length); + + /* request notify */ + batt->batt_level_cb_id = +diff --git a/profiles/cyclingspeed/cyclingspeed.c b/profiles/cyclingspeed/cyclingspeed.c +index e4477256..8c467fb9 100755 +--- a/profiles/cyclingspeed/cyclingspeed.c ++++ b/profiles/cyclingspeed/cyclingspeed.c +@@ -716,7 +716,7 @@ static void controlpoint_ind_handler(const uint8_t *pdu, uint16_t len, + case REQUEST_SUPPORTED_SENSOR_LOC: + if (rsp_code == RSP_SUCCESS) { + csc->num_locations = len; +- csc->locations = g_memdup(pdu, len); ++ csc->locations = g_memdup2(pdu, len); + } else { + error("Failed to read Supported Sendor Locations"); + } +diff --git a/profiles/deviceinfo/dis.c b/profiles/deviceinfo/dis.c +index 6126a776..64a00712 100755 +--- a/profiles/deviceinfo/dis.c ++++ b/profiles/deviceinfo/dis.c +@@ -156,7 +156,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 = g_memdup2(primary, sizeof(*dis->primary)); + + return bt_dis_ref(dis); + } +diff --git a/profiles/input/hog-lib.c b/profiles/input/hog-lib.c +index e96c969b..2d7826d7 100755 +--- a/profiles/input/hog-lib.c ++++ b/profiles/input/hog-lib.c +@@ -517,7 +517,7 @@ static void report_read_cb(guint8 status, const guint8 *pdu, guint16 len, + if (report->value) + g_free(report->value); + +- report->value = g_memdup(pdu, len); ++ report->value = g_memdup2(pdu, len); + report->len = len; + } + +@@ -1517,7 +1517,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 = g_memdup2(primary, sizeof(*primary)); + discover_char(hog, hog->attrib, primary->range.start, + primary->range.end, NULL, + char_discovered_cb, hog); +@@ -1531,7 +1531,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 = g_memdup2(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 df65d2c1..5c9a59fd 100755 +--- a/profiles/scanparam/scpp.c ++++ b/profiles/scanparam/scpp.c +@@ -123,7 +123,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 = g_memdup2(primary, sizeof(*scan->primary)); + + return bt_scpp_ref(scan); + } +diff --git a/profiles/tds/tds.c b/profiles/tds/tds.c +index 1c4d31b7..12641615 100644 +--- a/profiles/tds/tds.c ++++ b/profiles/tds/tds.c +@@ -735,7 +735,7 @@ static DBusMessage *set_tds_block_data(DBusConnection *conn, + g_free(ptr); + } + ptr = g_malloc0(sizeof(struct tds_block_data)); +- ptr->val = g_memdup(value, len); ++ ptr->val = g_memdup2(value, len); + ptr->len = len; + + return dbus_message_new_method_return(msg); +diff --git a/src/adapter.c b/src/adapter.c +index b8ebc905..1d22e287 100644 +--- a/src/adapter.c ++++ b/src/adapter.c +@@ -4216,7 +4216,7 @@ static int set_adv_data_device_name(uint8_t *adv_data, int adv_len, char *name) + if (!name) + return adv_len; + +- data = g_memdup(adv_data, adv_len); ++ data = g_memdup2(adv_data, adv_len); + if (!data) + return adv_len; + +@@ -4262,7 +4262,7 @@ static int set_adv_data_tx_power(uint8_t *adv_data, int adv_len, int8_t tx_power + int i, j; + uint8_t *data = NULL; + +- data = g_memdup(adv_data, adv_len); ++ data = g_memdup2(adv_data, adv_len); + if (!data) + return adv_len; + +diff --git a/src/attrib-server.c b/src/attrib-server.c +index 10b4a71a..b6794153 100755 +--- a/src/attrib-server.c ++++ b/src/attrib-server.c +@@ -393,7 +393,7 @@ static struct attribute *attrib_db_add_new(struct gatt_server *server, + + a = g_new0(struct attribute, 1); + a->len = len; +- a->data = g_memdup(value, len); ++ a->data = g_memdup2(value, len); + a->handle = handle; + a->uuid = *uuid; + a->read_req = read_req; +diff --git a/src/device.c b/src/device.c +index 3ff8c696..816278f2 100644 +--- a/src/device.c ++++ b/src/device.c +@@ -5054,7 +5054,7 @@ static void load_info(struct btd_device *device, const char *local, + if (device->manufacturer_data_len < DEV_MAX_MANUFACTURER_DATA_LEN) { + load_manufacturer_data_2digit(str, + device->manufacturer_data_len, buf); +- device->manufacturer_data = g_memdup(buf, ++ device->manufacturer_data = g_memdup2(buf, + device->manufacturer_data_len); + } + g_free(str); +@@ -9431,7 +9431,7 @@ void device_set_manufacturer_info(struct btd_device *device, struct eir_data *ei + if (eir->manufacturer_data_len == 0) + return; + +- device->manufacturer_data = g_memdup(eir->manufacturer_data, ++ device->manufacturer_data = g_memdup2(eir->manufacturer_data, + eir->manufacturer_data_len); + device->manufacturer_data_len = eir->manufacturer_data_len; + +diff --git a/src/eir.c b/src/eir.c +index b10dccaa..9f0ff979 100755 +--- a/src/eir.c ++++ b/src/eir.c +@@ -360,13 +360,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 = g_memdup2(data, 16); + break; + + case EIR_SSP_RANDOMIZER: + if (data_len < 16) + break; +- eir->randomizer = g_memdup(data, 16); ++ eir->randomizer = g_memdup2(data, 16); + break; + + case EIR_DEVICE_ID: +@@ -396,7 +396,7 @@ void eir_parse(struct eir_data *eir, const uint8_t *eir_data, uint8_t eir_len) + if (data_len < 1) + break; + +- eir->manufacturer_data = g_memdup(data, ++ eir->manufacturer_data = g_memdup2(data, + data_len); + eir->manufacturer_data_len = data_len; + #endif +diff --git a/tools/gatt-service.c b/tools/gatt-service.c +index 2ce8a1fd..17293e6d 100755 +--- a/tools/gatt-service.c ++++ b/tools/gatt-service.c +@@ -139,7 +139,7 @@ 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); ++ desc->value = g_memdup2(value, len); + desc->vlen = len; + + g_dbus_emit_property_changed(connection, desc->path, +@@ -277,7 +277,7 @@ 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); ++ chr->value = g_memdup2(value, len); + chr->vlen = len; + + g_dbus_emit_property_changed(connection, chr->path, GATT_CHR_IFACE, +@@ -604,7 +604,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 = g_memdup2(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 1bd9868d..0e337437 100644 +--- a/tools/mesh-gatt/gatt.c ++++ b/tools/mesh-gatt/gatt.c +@@ -351,7 +351,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 = g_memdup2(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 c92618ba..6df1243f 100755 +--- a/unit/test-avctp.c ++++ b/unit/test-avctp.c +@@ -66,7 +66,7 @@ struct context { + #define raw_pdu(args...) \ + { \ + .valid = true, \ +- .data = g_memdup(data(args), sizeof(data(args))), \ ++ .data = g_memdup2(data(args), sizeof(data(args))), \ + .size = sizeof(data(args)), \ + } + +@@ -77,7 +77,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 = g_memdup2(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 13c03d03..34a9e4f3 100755 +--- a/unit/test-avdtp.c ++++ b/unit/test-avdtp.c +@@ -61,7 +61,7 @@ struct test_data { + #define raw_pdu(args...) \ + { \ + .valid = true, \ +- .data = g_memdup(data(args), sizeof(data(args))), \ ++ .data = g_memdup2(data(args), sizeof(data(args))), \ + .size = sizeof(data(args)), \ + } + +@@ -69,7 +69,7 @@ struct test_data { + { \ + .valid = true, \ + .fragmented = true, \ +- .data = g_memdup(data(args), sizeof(data(args))), \ ++ .data = g_memdup2(data(args), sizeof(data(args))), \ + .size = sizeof(data(args)), \ + } + +@@ -80,7 +80,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 = g_memdup2(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 adf25f00..f15ecf6a 100755 +--- a/unit/test-avrcp.c ++++ b/unit/test-avrcp.c +@@ -74,7 +74,7 @@ struct context { + #define raw_pdu(args...) \ + { \ + .valid = true, \ +- .data = g_memdup(data(args), sizeof(data(args))), \ ++ .data = g_memdup2(data(args), sizeof(data(args))), \ + .size = sizeof(data(args)), \ + } + +@@ -82,7 +82,7 @@ struct context { + { \ + .valid = true, \ + .browse = true, \ +- .data = g_memdup(data(args), sizeof(data(args))), \ ++ .data = g_memdup2(data(args), sizeof(data(args))), \ + .size = sizeof(data(args)), \ + } + +@@ -90,7 +90,7 @@ struct context { + { \ + .valid = true, \ + .fragmented = true, \ +- .data = g_memdup(data(args), sizeof(data(args))), \ ++ .data = g_memdup2(data(args), sizeof(data(args))), \ + .size = sizeof(data(args)), \ + } + +@@ -98,7 +98,7 @@ struct context { + { \ + .valid = true, \ + .continuing = true, \ +- .data = g_memdup(data(args), sizeof(data(args))), \ ++ .data = g_memdup2(data(args), sizeof(data(args))), \ + .size = sizeof(data(args)), \ + } + +@@ -109,7 +109,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 = g_memdup2(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 7456868d..9169b02f 100755 +--- a/unit/test-gatt.c ++++ b/unit/test-gatt.c +@@ -86,7 +86,7 @@ struct context { + #define raw_pdu(args...) \ + { \ + .valid = true, \ +- .data = g_memdup(data(args), sizeof(data(args))), \ ++ .data = g_memdup2(data(args), sizeof(data(args))), \ + .size = sizeof(data(args)), \ + } + +@@ -107,7 +107,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 = g_memdup2(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 890eee65..414c0f8d 100755 +--- a/unit/test-hfp.c ++++ b/unit/test-hfp.c +@@ -63,7 +63,7 @@ struct test_data { + #define raw_pdu(args...) \ + { \ + .valid = true, \ +- .data = g_memdup(data(args), sizeof(data(args))), \ ++ .data = g_memdup2(data(args), sizeof(data(args))), \ + .size = sizeof(data(args)), \ + } + +@@ -75,7 +75,7 @@ struct test_data { + #define type_pdu(cmd_type, args...) \ + { \ + .valid = true, \ +- .data = g_memdup(data(args), sizeof(data(args))), \ ++ .data = g_memdup2(data(args), sizeof(data(args))), \ + .size = sizeof(data(args)), \ + .type = cmd_type, \ + } +@@ -83,7 +83,7 @@ struct test_data { + #define frg_pdu(args...) \ + { \ + .valid = true, \ +- .data = g_memdup(data(args), sizeof(data(args))), \ ++ .data = g_memdup2(data(args), sizeof(data(args))), \ + .size = sizeof(data(args)), \ + .fragmented = true, \ + } +@@ -95,7 +95,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 = g_memdup2(pdus, sizeof(pdus)); \ + data.result_func = result_function; \ + tester_add(name, &data, NULL, function, NULL); \ + data.test_handler = test_handler; \ +@@ -109,7 +109,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 = g_memdup2(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 99406c2b..e787cbcd 100755 +--- a/unit/test-hog.c ++++ b/unit/test-hog.c +@@ -71,7 +71,7 @@ struct context { + #define raw_pdu(args...) \ + { \ + .valid = true, \ +- .data = g_memdup(data(args), sizeof(data(args))), \ ++ .data = g_memdup2(data(args), sizeof(data(args))), \ + .size = sizeof(data(args)), \ + } + +@@ -87,7 +87,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 = g_memdup2(pdus, sizeof(pdus)); \ + tester_add(name, &data, NULL, function, NULL); \ + } while (0) + +diff --git a/unit/test-sdp.c b/unit/test-sdp.c +index 03501d02..23228a4a 100755 +--- a/unit/test-sdp.c ++++ b/unit/test-sdp.c +@@ -60,14 +60,14 @@ struct test_data { + #define raw_pdu(args...) \ + { \ + .valid = true, \ +- .raw_data = g_memdup(raw_data(args), sizeof(raw_data(args))), \ ++ .raw_data = g_memdup2(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 = g_memdup2(raw_data(args), sizeof(raw_data(args))), \ + .raw_size = sizeof(raw_data(args)), \ + .cont_len = cont, \ + } +@@ -79,7 +79,7 @@ struct test_data { + }; \ + static struct test_data data; \ + data.mtu = _mtu; \ +- data.pdu_list = g_memdup(pdus, sizeof(pdus)); \ ++ data.pdu_list = g_memdup2(pdus, sizeof(pdus)); \ + tester_add(name, &data, NULL, test_sdp, NULL); \ + } while (0) + +@@ -105,7 +105,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 = g_memdup2(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 320cd54d..5634ad51 100755 +--- a/unit/test-uhid.c ++++ b/unit/test-uhid.c +@@ -74,7 +74,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 = g_memdup2(pdus, sizeof(pdus)); \ + tester_add(name, &data, NULL, function, NULL); \ + } while (0) + +-- +2.25.1 + diff --git a/packaging/bluez.spec b/packaging/bluez.spec index e2cc767..7880451 100755 --- a/packaging/bluez.spec +++ b/packaging/bluez.spec @@ -23,6 +23,7 @@ Source101: obex-root-setup Source102: create-symlinks Source103: obex.sh Source1001: bluez.manifest +Patch : Use-g_memdup2-for-glib-2.70-upgrade.patch #Patch1 : bluez-ncurses.patch #Patch2 : disable-eir-unittest.patch #Requires: dbus >= 0.60 @@ -147,6 +148,7 @@ Contains bluetooth mesh daemon %prep %setup -q cp %{SOURCE1001} . +%patch -p1 %build autoreconf -fiv -- 2.7.4