0002-Use-g_memdup2-everywhere.patch 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998
  1. From 393a58bbe5174123ee9d52c03a75b08219642024 Mon Sep 17 00:00:00 2001
  2. From: Benjamin Berg <bberg@redhat.com>
  3. Date: Mon, 3 May 2021 15:06:36 +0200
  4. Subject: [PATCH] Use g_memdup2 everywhere
  5. ---
  6. android/a2dp.c | 8 ++---
  7. android/avctp.c | 4 +--
  8. android/avrcp-lib.c | 2 +-
  9. android/gatt.c | 4 +--
  10. android/hidhost.c | 2 +-
  11. android/tester-main.c | 70 +++++++++++++++++++-------------------
  12. attrib/gatt.c | 6 ++--
  13. client/gatt.c | 2 +-
  14. gobex/gobex-header.c | 4 +--
  15. gobex/gobex-packet.c | 2 +-
  16. obexd/src/obex.c | 2 +-
  17. plugins/neard.c | 6 ++--
  18. plugins/policy.c | 4 +--
  19. profiles/audio/avctp.c | 4 +--
  20. profiles/audio/avrcp.c | 6 ++--
  21. profiles/battery/bas.c | 2 +-
  22. profiles/battery/battery.c | 2 +-
  23. profiles/deviceinfo/dis.c | 2 +-
  24. profiles/input/hog-lib.c | 6 ++--
  25. profiles/scanparam/scpp.c | 2 +-
  26. src/attrib-server.c | 2 +-
  27. src/eir.c | 4 +--
  28. tools/gatt-service.c | 6 ++--
  29. tools/mesh-gatt/gatt.c | 2 +-
  30. unit/test-avctp.c | 4 +--
  31. unit/test-avdtp.c | 6 ++--
  32. unit/test-avrcp.c | 10 +++---
  33. unit/test-gatt.c | 4 +--
  34. unit/test-hfp.c | 10 +++---
  35. unit/test-hog.c | 4 +--
  36. unit/test-sdp.c | 8 ++---
  37. unit/test-uhid.c | 2 +-
  38. 32 files changed, 101 insertions(+), 101 deletions(-)
  39. diff --git a/android/a2dp.c b/android/a2dp.c
  40. index e24f793..1d9538a 100644
  41. --- a/android/a2dp.c
  42. +++ b/android/a2dp.c
  43. @@ -428,7 +428,7 @@ static struct a2dp_preset *sbc_select_range(void *caps, uint8_t caps_len,
  44. p = g_new0(struct a2dp_preset, 1);
  45. p->len = conf_len;
  46. - p->data = g_memdup(conf, p->len);
  47. + p->data = g_memdup2(conf, p->len);
  48. return p;
  49. }
  50. @@ -448,7 +448,7 @@ static struct a2dp_preset *aac_select_range(void *caps, uint8_t caps_len,
  51. p = g_new0(struct a2dp_preset, 1);
  52. p->len = conf_len;
  53. - p->data = g_memdup(conf, p->len);
  54. + p->data = g_memdup2(conf, p->len);
  55. return p;
  56. }
  57. @@ -1036,7 +1036,7 @@ static gboolean sep_setconf_ind(struct avdtp *session,
  58. preset = g_new0(struct a2dp_preset, 1);
  59. preset->len = cap->length - sizeof(*codec);
  60. - preset->data = g_memdup(codec->data, preset->len);
  61. + preset->data = g_memdup2(codec->data, preset->len);
  62. if (check_config(endpoint, preset) < 0) {
  63. preset_free(preset);
  64. @@ -1365,7 +1365,7 @@ static GSList *parse_presets(const struct audio_preset *p, uint8_t count,
  65. preset = g_new0(struct a2dp_preset, 1);
  66. preset->len = p->len;
  67. - preset->data = g_memdup(p->data, preset->len);
  68. + preset->data = g_memdup2(p->data, preset->len);
  69. l = g_slist_append(l, preset);
  70. len -= preset->len;
  71. diff --git a/android/avctp.c b/android/avctp.c
  72. index c2ea5f4..d1b8fe3 100644
  73. --- a/android/avctp.c
  74. +++ b/android/avctp.c
  75. @@ -1179,7 +1179,7 @@ static int avctp_send_req(struct avctp *session, uint8_t code, uint8_t subunit,
  76. for (i = 0; i < iov_cnt; i++) {
  77. pdu[i].iov_len = iov[i].iov_len;
  78. - pdu[i].iov_base = g_memdup(iov[i].iov_base, iov[i].iov_len);
  79. + pdu[i].iov_base = g_memdup2(iov[i].iov_base, iov[i].iov_len);
  80. }
  81. req = g_new0(struct avctp_control_req, 1);
  82. @@ -1220,7 +1220,7 @@ int avctp_send_browsing_req(struct avctp *session,
  83. for (i = 0; i < iov_cnt; i++) {
  84. pdu[i].iov_len = iov[i].iov_len;
  85. - pdu[i].iov_base = g_memdup(iov[i].iov_base, iov[i].iov_len);
  86. + pdu[i].iov_base = g_memdup2(iov[i].iov_base, iov[i].iov_len);
  87. }
  88. req = g_new0(struct avctp_browsing_req, 1);
  89. diff --git a/android/avrcp-lib.c b/android/avrcp-lib.c
  90. index 2007d09..ededdcf 100644
  91. --- a/android/avrcp-lib.c
  92. +++ b/android/avrcp-lib.c
  93. @@ -2620,7 +2620,7 @@ static char *parse_folder_list(uint8_t *params, uint16_t params_len,
  94. return NULL;
  95. }
  96. - folders[count] = g_memdup(&params[i], len);
  97. + folders[count] = g_memdup2(&params[i], len);
  98. i += len;
  99. }
  100. diff --git a/android/gatt.c b/android/gatt.c
  101. index a8a0c48..6e8c431 100644
  102. --- a/android/gatt.c
  103. +++ b/android/gatt.c
  104. @@ -1338,7 +1338,7 @@ static void discover_primary_cb(uint8_t status, GSList *services,
  105. }
  106. bt_uuid_to_uuid128(&uuid, &u128);
  107. - new_uuid = g_memdup(&u128.value.u128, sizeof(u128.value.u128));
  108. + new_uuid = g_memdup2(&u128.value.u128, sizeof(u128.value.u128));
  109. uuids = g_slist_prepend(uuids, new_uuid);
  110. }
  111. @@ -6633,7 +6633,7 @@ static uint8_t write_prep_request(const uint8_t *cmd, uint16_t cmd_len,
  112. queue_push_tail(dev->pending_requests, data);
  113. - data->value = g_memdup(value, vlen);
  114. + data->value = g_memdup2(value, vlen);
  115. data->length = vlen;
  116. if (!gatt_db_attribute_write(attrib, offset, value, vlen, cmd[0],
  117. diff --git a/android/hidhost.c b/android/hidhost.c
  118. index 016382e..6f0ec85 100644
  119. --- a/android/hidhost.c
  120. +++ b/android/hidhost.c
  121. @@ -689,7 +689,7 @@ static void hid_sdp_search_cb(sdp_list_t *recs, int err, gpointer data)
  122. goto fail;
  123. dev->rd_size = data->unitSize;
  124. - dev->rd_data = g_memdup(data->val.str, data->unitSize);
  125. + dev->rd_data = g_memdup2(data->val.str, data->unitSize);
  126. }
  127. }
  128. diff --git a/android/tester-main.c b/android/tester-main.c
  129. index 2bfa770..c09bc0a 100644
  130. --- a/android/tester-main.c
  131. +++ b/android/tester-main.c
  132. @@ -1253,7 +1253,7 @@ static bt_property_t *copy_properties(int num_properties,
  133. for (i = 0; i < num_properties; i++) {
  134. props[i].type = properties[i].type;
  135. props[i].len = properties[i].len;
  136. - props[i].val = g_memdup(properties[i].val, properties[i].len);
  137. + props[i].val = g_memdup2(properties[i].val, properties[i].len);
  138. }
  139. return props;
  140. @@ -1268,7 +1268,7 @@ static bt_property_t *repack_properties(int num_properties,
  141. for (i = 0; i < num_properties; i++) {
  142. props[i].type = properties[i]->type;
  143. props[i].len = properties[i]->len;
  144. - props[i].val = g_memdup(properties[i]->val, properties[i]->len);
  145. + props[i].val = g_memdup2(properties[i]->val, properties[i]->len);
  146. }
  147. return props;
  148. @@ -1281,7 +1281,7 @@ static bt_property_t *create_property(bt_property_type_t type, void *val,
  149. prop->type = type;
  150. prop->len = len;
  151. - prop->val = g_memdup(val, len);
  152. + prop->val = g_memdup2(val, len);
  153. return prop;
  154. }
  155. @@ -1615,7 +1615,7 @@ static void gattc_search_result_cb(int conn_id, btgatt_srvc_id_t *srvc_id)
  156. step->callback = CB_GATTC_SEARCH_RESULT;
  157. step->callback_result.conn_id = conn_id;
  158. - step->callback_result.service = g_memdup(srvc_id, sizeof(*srvc_id));
  159. + step->callback_result.service = g_memdup2(srvc_id, sizeof(*srvc_id));
  160. schedule_callback_verification(step);
  161. }
  162. @@ -1639,8 +1639,8 @@ static void gattc_get_characteristic_cb(int conn_id, int status,
  163. step->callback = CB_GATTC_GET_CHARACTERISTIC;
  164. step->callback_result.status = status;
  165. step->callback_result.conn_id = conn_id;
  166. - step->callback_result.service = g_memdup(srvc_id, sizeof(*srvc_id));
  167. - step->callback_result.characteristic = g_memdup(char_id,
  168. + step->callback_result.service = g_memdup2(srvc_id, sizeof(*srvc_id));
  169. + step->callback_result.characteristic = g_memdup2(char_id,
  170. sizeof(*char_id));
  171. step->callback_result.char_prop = char_prop;
  172. @@ -1656,10 +1656,10 @@ static void gattc_get_descriptor_cb(int conn_id, int status,
  173. step->callback = CB_GATTC_GET_DESCRIPTOR;
  174. step->callback_result.status = status;
  175. step->callback_result.conn_id = conn_id;
  176. - step->callback_result.service = g_memdup(srvc_id, sizeof(*srvc_id));
  177. - step->callback_result.characteristic = g_memdup(char_id,
  178. + step->callback_result.service = g_memdup2(srvc_id, sizeof(*srvc_id));
  179. + step->callback_result.characteristic = g_memdup2(char_id,
  180. sizeof(*char_id));
  181. - step->callback_result.descriptor = g_memdup(descr_id,
  182. + step->callback_result.descriptor = g_memdup2(descr_id,
  183. sizeof(*descr_id));
  184. schedule_callback_verification(step);
  185. @@ -1673,8 +1673,8 @@ static void gattc_get_included_service_cb(int conn_id, int status,
  186. step->callback = CB_GATTC_GET_INCLUDED_SERVICE;
  187. step->callback_result.status = status;
  188. step->callback_result.conn_id = conn_id;
  189. - step->callback_result.service = g_memdup(srvc_id, sizeof(*srvc_id));
  190. - step->callback_result.included = g_memdup(incl_srvc_id,
  191. + step->callback_result.service = g_memdup2(srvc_id, sizeof(*srvc_id));
  192. + step->callback_result.included = g_memdup2(incl_srvc_id,
  193. sizeof(*srvc_id));
  194. schedule_callback_verification(step);
  195. @@ -1688,7 +1688,7 @@ static void gattc_read_characteristic_cb(int conn_id, int status,
  196. step->callback = CB_GATTC_READ_CHARACTERISTIC;
  197. step->callback_result.status = status;
  198. step->callback_result.conn_id = conn_id;
  199. - step->callback_result.read_params = g_memdup(p_data, sizeof(*p_data));
  200. + step->callback_result.read_params = g_memdup2(p_data, sizeof(*p_data));
  201. schedule_callback_verification(step);
  202. }
  203. @@ -1701,7 +1701,7 @@ static void gattc_read_descriptor_cb(int conn_id, int status,
  204. step->callback = CB_GATTC_READ_DESCRIPTOR;
  205. step->callback_result.status = status;
  206. step->callback_result.conn_id = conn_id;
  207. - step->callback_result.read_params = g_memdup(p_data, sizeof(*p_data));
  208. + step->callback_result.read_params = g_memdup2(p_data, sizeof(*p_data));
  209. schedule_callback_verification(step);
  210. }
  211. @@ -1714,7 +1714,7 @@ static void gattc_write_characteristic_cb(int conn_id, int status,
  212. step->callback = CB_GATTC_WRITE_CHARACTERISTIC;
  213. step->callback_result.status = status;
  214. step->callback_result.conn_id = conn_id;
  215. - step->callback_result.write_params = g_memdup(p_data, sizeof(*p_data));
  216. + step->callback_result.write_params = g_memdup2(p_data, sizeof(*p_data));
  217. schedule_callback_verification(step);
  218. }
  219. @@ -1727,7 +1727,7 @@ static void gattc_write_descriptor_cb(int conn_id, int status,
  220. step->callback = CB_GATTC_WRITE_DESCRIPTOR;
  221. step->callback_result.status = status;
  222. step->callback_result.conn_id = conn_id;
  223. - step->callback_result.write_params = g_memdup(p_data, sizeof(*p_data));
  224. + step->callback_result.write_params = g_memdup2(p_data, sizeof(*p_data));
  225. schedule_callback_verification(step);
  226. }
  227. @@ -1742,8 +1742,8 @@ static void gattc_register_for_notification_cb(int conn_id, int registered,
  228. step->callback = CB_GATTC_REGISTER_FOR_NOTIFICATION;
  229. step->callback_result.status = status;
  230. step->callback_result.conn_id = conn_id;
  231. - step->callback_result.service = g_memdup(srvc_id, sizeof(*srvc_id));
  232. - step->callback_result.characteristic = g_memdup(char_id,
  233. + step->callback_result.service = g_memdup2(srvc_id, sizeof(*srvc_id));
  234. + step->callback_result.characteristic = g_memdup2(char_id,
  235. sizeof(*char_id));
  236. step->callback_result.notification_registered = registered;
  237. @@ -1756,7 +1756,7 @@ static void gattc_notif_cb(int conn_id, btgatt_notify_params_t *p_data)
  238. step->callback = CB_GATTC_NOTIFY;
  239. step->callback_result.conn_id = conn_id;
  240. - step->callback_result.notify_params = g_memdup(p_data, sizeof(*p_data));
  241. + step->callback_result.notify_params = g_memdup2(p_data, sizeof(*p_data));
  242. schedule_callback_verification(step);
  243. }
  244. @@ -1827,8 +1827,8 @@ static void gatts_service_added_cb(int status, int server_if,
  245. step->callback_result.status = status;
  246. step->callback_result.gatt_app_id = server_if;
  247. - step->callback_result.service = g_memdup(srvc_id, sizeof(*srvc_id));
  248. - step->callback_result.srvc_handle = g_memdup(&srvc_handle,
  249. + step->callback_result.service = g_memdup2(srvc_id, sizeof(*srvc_id));
  250. + step->callback_result.srvc_handle = g_memdup2(&srvc_handle,
  251. sizeof(srvc_handle));
  252. schedule_callback_verification(step);
  253. @@ -1844,9 +1844,9 @@ static void gatts_included_service_added_cb(int status, int server_if,
  254. step->callback_result.status = status;
  255. step->callback_result.gatt_app_id = server_if;
  256. - step->callback_result.srvc_handle = g_memdup(&srvc_handle,
  257. + step->callback_result.srvc_handle = g_memdup2(&srvc_handle,
  258. sizeof(srvc_handle));
  259. - step->callback_result.inc_srvc_handle = g_memdup(&inc_srvc_handle,
  260. + step->callback_result.inc_srvc_handle = g_memdup2(&inc_srvc_handle,
  261. sizeof(inc_srvc_handle));
  262. schedule_callback_verification(step);
  263. @@ -1863,10 +1863,10 @@ static void gatts_characteristic_added_cb(int status, int server_if,
  264. step->callback_result.status = status;
  265. step->callback_result.gatt_app_id = server_if;
  266. - step->callback_result.srvc_handle = g_memdup(&srvc_handle,
  267. + step->callback_result.srvc_handle = g_memdup2(&srvc_handle,
  268. sizeof(srvc_handle));
  269. - step->callback_result.uuid = g_memdup(uuid, sizeof(*uuid));
  270. - step->callback_result.char_handle = g_memdup(&char_handle,
  271. + step->callback_result.uuid = g_memdup2(uuid, sizeof(*uuid));
  272. + step->callback_result.char_handle = g_memdup2(&char_handle,
  273. sizeof(char_handle));
  274. schedule_callback_verification(step);
  275. @@ -1883,10 +1883,10 @@ static void gatts_descriptor_added_cb(int status, int server_if,
  276. step->callback_result.status = status;
  277. step->callback_result.gatt_app_id = server_if;
  278. - step->callback_result.srvc_handle = g_memdup(&srvc_handle,
  279. + step->callback_result.srvc_handle = g_memdup2(&srvc_handle,
  280. sizeof(srvc_handle));
  281. - step->callback_result.uuid = g_memdup(uuid, sizeof(*uuid));
  282. - step->callback_result.desc_handle = g_memdup(&desc_handle,
  283. + step->callback_result.uuid = g_memdup2(uuid, sizeof(*uuid));
  284. + step->callback_result.desc_handle = g_memdup2(&desc_handle,
  285. sizeof(desc_handle));
  286. schedule_callback_verification(step);
  287. @@ -1900,7 +1900,7 @@ static void gatts_service_started_cb(int status, int server_if, int srvc_handle)
  288. step->callback_result.status = status;
  289. step->callback_result.gatt_app_id = server_if;
  290. - step->callback_result.srvc_handle = g_memdup(&srvc_handle,
  291. + step->callback_result.srvc_handle = g_memdup2(&srvc_handle,
  292. sizeof(srvc_handle));
  293. schedule_callback_verification(step);
  294. @@ -1914,7 +1914,7 @@ static void gatts_service_stopped_cb(int status, int server_if, int srvc_handle)
  295. step->callback_result.status = status;
  296. step->callback_result.gatt_app_id = server_if;
  297. - step->callback_result.srvc_handle = g_memdup(&srvc_handle,
  298. + step->callback_result.srvc_handle = g_memdup2(&srvc_handle,
  299. sizeof(srvc_handle));
  300. schedule_callback_verification(step);
  301. @@ -1928,7 +1928,7 @@ static void gatts_service_deleted_cb(int status, int server_if, int srvc_handle)
  302. step->callback_result.status = status;
  303. step->callback_result.gatt_app_id = server_if;
  304. - step->callback_result.srvc_handle = g_memdup(&srvc_handle,
  305. + step->callback_result.srvc_handle = g_memdup2(&srvc_handle,
  306. sizeof(srvc_handle));
  307. schedule_callback_verification(step);
  308. @@ -1945,7 +1945,7 @@ static void gatts_request_read_cb(int conn_id, int trans_id, bt_bdaddr_t *bda,
  309. step->callback_result.conn_id = conn_id;
  310. step->callback_result.trans_id = trans_id;
  311. - step->callback_result.attr_handle = g_memdup(&attr_handle,
  312. + step->callback_result.attr_handle = g_memdup2(&attr_handle,
  313. sizeof(attr_handle));
  314. step->callback_result.offset = offset;
  315. step->callback_result.is_long = is_long;
  316. @@ -1974,13 +1974,13 @@ static void gatts_request_write_cb(int conn_id, int trans_id, bt_bdaddr_t *bda,
  317. step->callback_result.conn_id = conn_id;
  318. step->callback_result.trans_id = trans_id;
  319. - step->callback_result.attr_handle = g_memdup(&attr_handle,
  320. + step->callback_result.attr_handle = g_memdup2(&attr_handle,
  321. sizeof(attr_handle));
  322. step->callback_result.offset = offset;
  323. step->callback_result.length = length;
  324. step->callback_result.need_rsp = need_rsp;
  325. step->callback_result.is_prep = is_prep;
  326. - step->callback_result.value = g_memdup(&value, length);
  327. + step->callback_result.value = g_memdup2(&value, length);
  328. /* Utilize property verification mechanism for bdaddr */
  329. props[0] = create_property(BT_PROPERTY_BDADDR, bda, sizeof(*bda));
  330. @@ -2169,7 +2169,7 @@ static btmce_mas_instance_t *copy_mas_instances(int num_instances,
  331. inst[i].id = instances[i].id;
  332. inst[i].scn = instances[i].scn;
  333. inst[i].msg_types = instances[i].msg_types;
  334. - inst[i].p_name = g_memdup(instances[i].p_name,
  335. + inst[i].p_name = g_memdup2(instances[i].p_name,
  336. strlen(instances[i].p_name));
  337. }
  338. diff --git a/attrib/gatt.c b/attrib/gatt.c
  339. index 46b2ca3..1f30764 100644
  340. --- a/attrib/gatt.c
  341. +++ b/attrib/gatt.c
  342. @@ -696,7 +696,7 @@ guint gatt_discover_char(GAttrib *attrib, uint16_t start, uint16_t end,
  343. dc->user_data = user_data;
  344. dc->end = end;
  345. dc->start = start;
  346. - dc->uuid = g_memdup(uuid, sizeof(bt_uuid_t));
  347. + dc->uuid = g_memdup2(uuid, sizeof(bt_uuid_t));
  348. dc->id = g_attrib_send(attrib, 0, buf, plen, char_discovered_cb,
  349. discover_char_ref(dc), discover_char_unref);
  350. @@ -964,7 +964,7 @@ guint gatt_write_char(GAttrib *attrib, uint16_t handle, const uint8_t *value,
  351. long_write->func = func;
  352. long_write->user_data = user_data;
  353. long_write->handle = handle;
  354. - long_write->value = g_memdup(value, vlen);
  355. + long_write->value = g_memdup2(value, vlen);
  356. long_write->vlen = vlen;
  357. return prepare_write(long_write);
  358. @@ -1130,7 +1130,7 @@ guint gatt_discover_desc(GAttrib *attrib, uint16_t start, uint16_t end,
  359. dd->user_data = user_data;
  360. dd->start = start;
  361. dd->end = end;
  362. - dd->uuid = g_memdup(uuid, sizeof(bt_uuid_t));
  363. + dd->uuid = g_memdup2(uuid, sizeof(bt_uuid_t));
  364. dd->id = g_attrib_send(attrib, 0, buf, plen, desc_discovered_cb,
  365. discover_desc_ref(dd), discover_desc_unref);
  366. diff --git a/client/gatt.c b/client/gatt.c
  367. index 21fd38e..d302183 100644
  368. --- a/client/gatt.c
  369. +++ b/client/gatt.c
  370. @@ -790,7 +790,7 @@ static uint8_t *str2bytearray(char *arg, size_t *val_len)
  371. *val_len = i;
  372. - return g_memdup(value, i);
  373. + return g_memdup2(value, i);
  374. }
  375. void gatt_write_attribute(GDBusProxy *proxy, int argc, char *argv[])
  376. diff --git a/gobex/gobex-header.c b/gobex/gobex-header.c
  377. index 011d33d..c56be2f 100644
  378. --- a/gobex/gobex-header.c
  379. +++ b/gobex/gobex-header.c
  380. @@ -222,7 +222,7 @@ GObexHeader *g_obex_header_decode(const void *data, gsize len,
  381. switch (data_policy) {
  382. case G_OBEX_DATA_COPY:
  383. - header->v.data = g_memdup(ptr, header->vlen);
  384. + header->v.data = g_memdup2(ptr, header->vlen);
  385. break;
  386. case G_OBEX_DATA_REF:
  387. header->extdata = TRUE;
  388. @@ -410,7 +410,7 @@ GObexHeader *g_obex_header_new_bytes(guint8 id, const void *data, gsize len)
  389. header->id = id;
  390. header->vlen = len;
  391. header->hlen = len + 3;
  392. - header->v.data = g_memdup(data, len);
  393. + header->v.data = g_memdup2(data, len);
  394. return header;
  395. }
  396. diff --git a/gobex/gobex-packet.c b/gobex/gobex-packet.c
  397. index 11937a5..18da6ea 100644
  398. --- a/gobex/gobex-packet.c
  399. +++ b/gobex/gobex-packet.c
  400. @@ -201,7 +201,7 @@ gboolean g_obex_packet_set_data(GObexPacket *pkt, const void *data, gsize len,
  401. switch (data_policy) {
  402. case G_OBEX_DATA_COPY:
  403. - pkt->data.buf = g_memdup(data, len);
  404. + pkt->data.buf = g_memdup2(data, len);
  405. break;
  406. case G_OBEX_DATA_REF:
  407. pkt->data.buf_ref = data;
  408. diff --git a/obexd/src/obex.c b/obexd/src/obex.c
  409. index 9f992ec..151d956 100644
  410. --- a/obexd/src/obex.c
  411. +++ b/obexd/src/obex.c
  412. @@ -594,7 +594,7 @@ static void parse_apparam(struct obex_session *os, GObexPacket *req)
  413. if (!g_obex_header_get_bytes(hdr, &apparam, &len))
  414. return;
  415. - os->apparam = g_memdup(apparam, len);
  416. + os->apparam = g_memdup2(apparam, len);
  417. os->apparam_len = len;
  418. DBG("APPARAM");
  419. }
  420. diff --git a/plugins/neard.c b/plugins/neard.c
  421. index e07b511..a806bb7 100644
  422. --- a/plugins/neard.c
  423. +++ b/plugins/neard.c
  424. @@ -407,10 +407,10 @@ static int process_nokia_long (void *data, size_t size, uint8_t marker,
  425. remote->name = g_strndup((char *)n->name, n->name_len);
  426. if (marker == 0x01) {
  427. - remote->pin = g_memdup(n->authentication, 4);
  428. + remote->pin = g_memdup2(n->authentication, 4);
  429. remote->pin_len = 4;
  430. } else if (marker == 0x02) {
  431. - remote->pin = g_memdup(n->authentication, 16);
  432. + remote->pin = g_memdup2(n->authentication, 16);
  433. remote->pin_len = 16;
  434. }
  435. @@ -439,7 +439,7 @@ static int process_nokia_short (void *data, size_t size,
  436. if (n->name_len > 0)
  437. remote->name = g_strndup((char *)n->name, n->name_len);
  438. - remote->pin = g_memdup(n->authentication, 4);
  439. + remote->pin = g_memdup2(n->authentication, 4);
  440. remote->pin_len = 4;
  441. return 0;
  442. diff --git a/plugins/policy.c b/plugins/policy.c
  443. index bf93df0..79943fc 100644
  444. --- a/plugins/policy.c
  445. +++ b/plugins/policy.c
  446. @@ -855,7 +855,7 @@ static int policy_init(void)
  447. reconnect_attempts = default_attempts;
  448. reconnect_intervals_len = sizeof(default_intervals) /
  449. sizeof(*reconnect_intervals);
  450. - reconnect_intervals = g_memdup(default_intervals,
  451. + reconnect_intervals = g_memdup2(default_intervals,
  452. sizeof(default_intervals));
  453. goto done;
  454. }
  455. @@ -886,7 +886,7 @@ static int policy_init(void)
  456. g_clear_error(&gerr);
  457. reconnect_intervals_len = sizeof(default_intervals) /
  458. sizeof(*reconnect_intervals);
  459. - reconnect_intervals = g_memdup(default_intervals,
  460. + reconnect_intervals = g_memdup2(default_intervals,
  461. sizeof(default_intervals));
  462. }
  463. diff --git a/profiles/audio/avctp.c b/profiles/audio/avctp.c
  464. index 50de336..2733a76 100644
  465. --- a/profiles/audio/avctp.c
  466. +++ b/profiles/audio/avctp.c
  467. @@ -1731,7 +1731,7 @@ static int avctp_send_req(struct avctp *session, uint8_t code,
  468. req->subunit = subunit;
  469. req->op = opcode;
  470. req->func = func;
  471. - req->operands = g_memdup(operands, operand_count);
  472. + req->operands = g_memdup2(operands, operand_count);
  473. req->operand_count = operand_count;
  474. req->user_data = user_data;
  475. @@ -1769,7 +1769,7 @@ int avctp_send_browsing_req(struct avctp *session,
  476. req = g_new0(struct avctp_browsing_req, 1);
  477. req->func = func;
  478. - req->operands = g_memdup(operands, operand_count);
  479. + req->operands = g_memdup2(operands, operand_count);
  480. req->operand_count = operand_count;
  481. req->user_data = user_data;
  482. diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
  483. index 05dd791..e23228d 100644
  484. --- a/profiles/audio/avrcp.c
  485. +++ b/profiles/audio/avrcp.c
  486. @@ -1297,7 +1297,7 @@ static uint8_t avrcp_handle_get_current_player_value(struct avrcp *session,
  487. * Save a copy of requested settings because we can override them
  488. * while responding
  489. */
  490. - settings = g_memdup(&pdu->params[1], pdu->params[0]);
  491. + settings = g_memdup2(&pdu->params[1], pdu->params[0]);
  492. len = 0;
  493. /*
  494. @@ -2786,7 +2786,7 @@ static gboolean avrcp_set_browsed_player_rsp(struct avctp *conn,
  495. break;
  496. }
  497. - folders[count] = g_memdup(&pdu->params[i], len);
  498. + folders[count] = g_memdup2(&pdu->params[i], len);
  499. i += len;
  500. }
  501. @@ -2873,7 +2873,7 @@ static void avrcp_player_parse_features(struct avrcp_player *player,
  502. {
  503. struct media_player *mp = player->user_data;
  504. - player->features = g_memdup(features, 16);
  505. + player->features = g_memdup2(features, 16);
  506. if (features[7] & 0x08) {
  507. media_player_set_browsable(mp, true);
  508. diff --git a/profiles/battery/bas.c b/profiles/battery/bas.c
  509. index 3c6173b..b223fbe 100644
  510. --- a/profiles/battery/bas.c
  511. +++ b/profiles/battery/bas.c
  512. @@ -75,7 +75,7 @@ struct bt_bas *bt_bas_new(void *primary)
  513. bas->gatt_op = queue_new();
  514. if (primary)
  515. - bas->primary = g_memdup(primary, sizeof(*bas->primary));
  516. + bas->primary = g_memdup2(primary, sizeof(*bas->primary));
  517. return bt_bas_ref(bas);
  518. }
  519. diff --git a/profiles/battery/battery.c b/profiles/battery/battery.c
  520. index 176d127..3b5aa5c 100644
  521. --- a/profiles/battery/battery.c
  522. +++ b/profiles/battery/battery.c
  523. @@ -159,7 +159,7 @@ static void read_initial_battery_level_cb(bool success,
  524. if (!length)
  525. return;
  526. - batt->initial_value = g_memdup(value, length);
  527. + batt->initial_value = g_memdup2(value, length);
  528. /* request notify */
  529. batt->batt_level_cb_id =
  530. diff --git a/profiles/deviceinfo/dis.c b/profiles/deviceinfo/dis.c
  531. index 87fa633..79d98c3 100644
  532. --- a/profiles/deviceinfo/dis.c
  533. +++ b/profiles/deviceinfo/dis.c
  534. @@ -143,7 +143,7 @@ struct bt_dis *bt_dis_new_primary(void *primary)
  535. dis->gatt_op = queue_new();
  536. if (primary)
  537. - dis->primary = g_memdup(primary, sizeof(*dis->primary));
  538. + dis->primary = g_memdup2(primary, sizeof(*dis->primary));
  539. return bt_dis_ref(dis);
  540. }
  541. diff --git a/profiles/input/hog-lib.c b/profiles/input/hog-lib.c
  542. index e5e3d3e..3652bdf 100644
  543. --- a/profiles/input/hog-lib.c
  544. +++ b/profiles/input/hog-lib.c
  545. @@ -514,7 +514,7 @@ static void report_read_cb(guint8 status, const guint8 *pdu, guint16 len,
  546. if (report->value)
  547. g_free(report->value);
  548. - report->value = g_memdup(pdu, len);
  549. + report->value = g_memdup2(pdu, len);
  550. report->len = len;
  551. }
  552. @@ -1595,7 +1595,7 @@ static void hog_attach_hog(struct bt_hog *hog, struct gatt_primary *primary)
  553. struct bt_hog *instance;
  554. if (!hog->primary) {
  555. - hog->primary = g_memdup(primary, sizeof(*primary));
  556. + hog->primary = g_memdup2(primary, sizeof(*primary));
  557. discover_char(hog, hog->attrib, primary->range.start,
  558. primary->range.end, NULL,
  559. char_discovered_cb, hog);
  560. @@ -1609,7 +1609,7 @@ static void hog_attach_hog(struct bt_hog *hog, struct gatt_primary *primary)
  561. if (!instance)
  562. return;
  563. - instance->primary = g_memdup(primary, sizeof(*primary));
  564. + instance->primary = g_memdup2(primary, sizeof(*primary));
  565. find_included(instance, hog->attrib, primary->range.start,
  566. primary->range.end, find_included_cb, instance);
  567. diff --git a/profiles/scanparam/scpp.c b/profiles/scanparam/scpp.c
  568. index da38a6a..1134360 100644
  569. --- a/profiles/scanparam/scpp.c
  570. +++ b/profiles/scanparam/scpp.c
  571. @@ -110,7 +110,7 @@ struct bt_scpp *bt_scpp_new(void *primary)
  572. scan->gatt_op = queue_new();
  573. if (primary)
  574. - scan->primary = g_memdup(primary, sizeof(*scan->primary));
  575. + scan->primary = g_memdup2(primary, sizeof(*scan->primary));
  576. return bt_scpp_ref(scan);
  577. }
  578. diff --git a/src/attrib-server.c b/src/attrib-server.c
  579. index 5a178f9..ce412c3 100644
  580. --- a/src/attrib-server.c
  581. +++ b/src/attrib-server.c
  582. @@ -339,7 +339,7 @@ static struct attribute *attrib_db_add_new(struct gatt_server *server,
  583. a = g_new0(struct attribute, 1);
  584. a->len = len;
  585. - a->data = g_memdup(value, len);
  586. + a->data = g_memdup2(value, len);
  587. a->handle = handle;
  588. a->uuid = *uuid;
  589. a->read_req = read_req;
  590. diff --git a/src/eir.c b/src/eir.c
  591. index 0f5d14f..ceeb5f7 100644
  592. --- a/src/eir.c
  593. +++ b/src/eir.c
  594. @@ -323,13 +323,13 @@ void eir_parse(struct eir_data *eir, const uint8_t *eir_data, uint8_t eir_len)
  595. case EIR_SSP_HASH:
  596. if (data_len < 16)
  597. break;
  598. - eir->hash = g_memdup(data, 16);
  599. + eir->hash = g_memdup2(data, 16);
  600. break;
  601. case EIR_SSP_RANDOMIZER:
  602. if (data_len < 16)
  603. break;
  604. - eir->randomizer = g_memdup(data, 16);
  605. + eir->randomizer = g_memdup2(data, 16);
  606. break;
  607. case EIR_DEVICE_ID:
  608. diff --git a/tools/gatt-service.c b/tools/gatt-service.c
  609. index 631c4f2..1e272a5 100644
  610. --- a/tools/gatt-service.c
  611. +++ b/tools/gatt-service.c
  612. @@ -127,7 +127,7 @@ static gboolean desc_get_value(const GDBusPropertyTable *property,
  613. static void desc_write(struct descriptor *desc, const uint8_t *value, int len)
  614. {
  615. g_free(desc->value);
  616. - desc->value = g_memdup(value, len);
  617. + desc->value = g_memdup2(value, len);
  618. desc->vlen = len;
  619. g_dbus_emit_property_changed(connection, desc->path,
  620. @@ -265,7 +265,7 @@ static gboolean chr_get_props(const GDBusPropertyTable *property,
  621. static void chr_write(struct characteristic *chr, const uint8_t *value, int len)
  622. {
  623. g_free(chr->value);
  624. - chr->value = g_memdup(value, len);
  625. + chr->value = g_memdup2(value, len);
  626. chr->vlen = len;
  627. g_dbus_emit_property_changed(connection, chr->path, GATT_CHR_IFACE,
  628. @@ -592,7 +592,7 @@ static gboolean register_characteristic(const char *chr_uuid,
  629. chr = g_new0(struct characteristic, 1);
  630. chr->uuid = g_strdup(chr_uuid);
  631. - chr->value = g_memdup(value, vlen);
  632. + chr->value = g_memdup2(value, vlen);
  633. chr->vlen = vlen;
  634. chr->props = props;
  635. chr->service = g_strdup(service_path);
  636. diff --git a/tools/mesh-gatt/gatt.c b/tools/mesh-gatt/gatt.c
  637. index b99234f..d7685f0 100644
  638. --- a/tools/mesh-gatt/gatt.c
  639. +++ b/tools/mesh-gatt/gatt.c
  640. @@ -338,7 +338,7 @@ bool mesh_gatt_write(GDBusProxy *proxy, uint8_t *buf, uint16_t len,
  641. /* TODO: should keep in queue in case we need to cancel write? */
  642. data->gatt_len = len;
  643. - data->gatt_data = g_memdup(buf, len);
  644. + data->gatt_data = g_memdup2(buf, len);
  645. data->gatt_data[0] &= GATT_TYPE_MASK;
  646. data->iov.iov_base = data->gatt_data;
  647. data->iov.iov_len = len;
  648. diff --git a/unit/test-avctp.c b/unit/test-avctp.c
  649. index fa7db59..0bd138e 100644
  650. --- a/unit/test-avctp.c
  651. +++ b/unit/test-avctp.c
  652. @@ -53,7 +53,7 @@ struct context {
  653. #define raw_pdu(args...) \
  654. { \
  655. .valid = true, \
  656. - .data = g_memdup(data(args), sizeof(data(args))), \
  657. + .data = g_memdup2(data(args), sizeof(data(args))), \
  658. .size = sizeof(data(args)), \
  659. }
  660. @@ -64,7 +64,7 @@ struct context {
  661. }; \
  662. static struct test_data data; \
  663. data.test_name = g_strdup(name); \
  664. - data.pdu_list = g_memdup(pdus, sizeof(pdus)); \
  665. + data.pdu_list = g_memdup2(pdus, sizeof(pdus)); \
  666. tester_add(name, &data, NULL, function, NULL); \
  667. } while (0)
  668. diff --git a/unit/test-avdtp.c b/unit/test-avdtp.c
  669. index f5340d6..d6fdd3d 100644
  670. --- a/unit/test-avdtp.c
  671. +++ b/unit/test-avdtp.c
  672. @@ -48,7 +48,7 @@ struct test_data {
  673. #define raw_pdu(args...) \
  674. { \
  675. .valid = true, \
  676. - .data = g_memdup(data(args), sizeof(data(args))), \
  677. + .data = g_memdup2(data(args), sizeof(data(args))), \
  678. .size = sizeof(data(args)), \
  679. }
  680. @@ -56,7 +56,7 @@ struct test_data {
  681. { \
  682. .valid = true, \
  683. .fragmented = true, \
  684. - .data = g_memdup(data(args), sizeof(data(args))), \
  685. + .data = g_memdup2(data(args), sizeof(data(args))), \
  686. .size = sizeof(data(args)), \
  687. }
  688. @@ -67,7 +67,7 @@ struct test_data {
  689. }; \
  690. static struct test_data data; \
  691. data.test_name = g_strdup(name); \
  692. - data.pdu_list = g_memdup(pdus, sizeof(pdus)); \
  693. + data.pdu_list = g_memdup2(pdus, sizeof(pdus)); \
  694. tester_add(name, &data, NULL, function, NULL); \
  695. } while (0)
  696. diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
  697. index 34a7037..0c860e3 100644
  698. --- a/unit/test-avrcp.c
  699. +++ b/unit/test-avrcp.c
  700. @@ -61,7 +61,7 @@ struct context {
  701. #define raw_pdu(args...) \
  702. { \
  703. .valid = true, \
  704. - .data = g_memdup(data(args), sizeof(data(args))), \
  705. + .data = g_memdup2(data(args), sizeof(data(args))), \
  706. .size = sizeof(data(args)), \
  707. }
  708. @@ -69,7 +69,7 @@ struct context {
  709. { \
  710. .valid = true, \
  711. .browse = true, \
  712. - .data = g_memdup(data(args), sizeof(data(args))), \
  713. + .data = g_memdup2(data(args), sizeof(data(args))), \
  714. .size = sizeof(data(args)), \
  715. }
  716. @@ -77,7 +77,7 @@ struct context {
  717. { \
  718. .valid = true, \
  719. .fragmented = true, \
  720. - .data = g_memdup(data(args), sizeof(data(args))), \
  721. + .data = g_memdup2(data(args), sizeof(data(args))), \
  722. .size = sizeof(data(args)), \
  723. }
  724. @@ -85,7 +85,7 @@ struct context {
  725. { \
  726. .valid = true, \
  727. .continuing = true, \
  728. - .data = g_memdup(data(args), sizeof(data(args))), \
  729. + .data = g_memdup2(data(args), sizeof(data(args))), \
  730. .size = sizeof(data(args)), \
  731. }
  732. @@ -96,7 +96,7 @@ struct context {
  733. }; \
  734. static struct test_data data; \
  735. data.test_name = g_strdup(name); \
  736. - data.pdu_list = g_memdup(pdus, sizeof(pdus)); \
  737. + data.pdu_list = g_memdup2(pdus, sizeof(pdus)); \
  738. tester_add(name, &data, NULL, function, NULL); \
  739. } while (0)
  740. diff --git a/unit/test-gatt.c b/unit/test-gatt.c
  741. index 4aa87d0..ab16818 100644
  742. --- a/unit/test-gatt.c
  743. +++ b/unit/test-gatt.c
  744. @@ -73,7 +73,7 @@ struct context {
  745. #define raw_pdu(args...) \
  746. { \
  747. .valid = true, \
  748. - .data = g_memdup(data(args), sizeof(data(args))), \
  749. + .data = g_memdup2(data(args), sizeof(data(args))), \
  750. .size = sizeof(data(args)), \
  751. }
  752. @@ -94,7 +94,7 @@ struct context {
  753. data.uuid = bt_uuid; \
  754. data.step = test_step; \
  755. data.source_db = db; \
  756. - data.pdu_list = g_memdup(pdus, sizeof(pdus)); \
  757. + data.pdu_list = g_memdup2(pdus, sizeof(pdus)); \
  758. tester_add(name, &data, NULL, function, NULL); \
  759. } while (0)
  760. diff --git a/unit/test-hfp.c b/unit/test-hfp.c
  761. index f504724..6afc145 100644
  762. --- a/unit/test-hfp.c
  763. +++ b/unit/test-hfp.c
  764. @@ -50,7 +50,7 @@ struct test_data {
  765. #define raw_pdu(args...) \
  766. { \
  767. .valid = true, \
  768. - .data = g_memdup(data(args), sizeof(data(args))), \
  769. + .data = g_memdup2(data(args), sizeof(data(args))), \
  770. .size = sizeof(data(args)), \
  771. }
  772. @@ -62,7 +62,7 @@ struct test_data {
  773. #define type_pdu(cmd_type, args...) \
  774. { \
  775. .valid = true, \
  776. - .data = g_memdup(data(args), sizeof(data(args))), \
  777. + .data = g_memdup2(data(args), sizeof(data(args))), \
  778. .size = sizeof(data(args)), \
  779. .type = cmd_type, \
  780. }
  781. @@ -70,7 +70,7 @@ struct test_data {
  782. #define frg_pdu(args...) \
  783. { \
  784. .valid = true, \
  785. - .data = g_memdup(data(args), sizeof(data(args))), \
  786. + .data = g_memdup2(data(args), sizeof(data(args))), \
  787. .size = sizeof(data(args)), \
  788. .fragmented = true, \
  789. }
  790. @@ -82,7 +82,7 @@ struct test_data {
  791. }; \
  792. static struct test_data data; \
  793. data.test_name = g_strdup(name); \
  794. - data.pdu_list = g_memdup(pdus, sizeof(pdus)); \
  795. + data.pdu_list = g_memdup2(pdus, sizeof(pdus)); \
  796. data.result_func = result_function; \
  797. tester_add(name, &data, NULL, function, NULL); \
  798. data.test_handler = test_handler; \
  799. @@ -96,7 +96,7 @@ struct test_data {
  800. }; \
  801. static struct test_data data; \
  802. data.test_name = g_strdup(name); \
  803. - data.pdu_list = g_memdup(pdus, sizeof(pdus)); \
  804. + data.pdu_list = g_memdup2(pdus, sizeof(pdus)); \
  805. data.hf_result_func = result_func; \
  806. data.response_func = response_function; \
  807. tester_add(name, &data, NULL, function, NULL); \
  808. diff --git a/unit/test-hog.c b/unit/test-hog.c
  809. index e6d4aff..edf0633 100644
  810. --- a/unit/test-hog.c
  811. +++ b/unit/test-hog.c
  812. @@ -59,7 +59,7 @@ struct context {
  813. #define raw_pdu(args...) \
  814. { \
  815. .valid = true, \
  816. - .data = g_memdup(data(args), sizeof(data(args))), \
  817. + .data = g_memdup2(data(args), sizeof(data(args))), \
  818. .size = sizeof(data(args)), \
  819. }
  820. @@ -75,7 +75,7 @@ struct context {
  821. }; \
  822. static struct test_data data; \
  823. data.test_name = g_strdup(name); \
  824. - data.pdu_list = g_memdup(pdus, sizeof(pdus)); \
  825. + data.pdu_list = g_memdup2(pdus, sizeof(pdus)); \
  826. tester_add(name, &data, NULL, function, NULL); \
  827. } while (0)
  828. diff --git a/unit/test-sdp.c b/unit/test-sdp.c
  829. index d3a885f..3a003ff 100644
  830. --- a/unit/test-sdp.c
  831. +++ b/unit/test-sdp.c
  832. @@ -47,14 +47,14 @@ struct test_data {
  833. #define raw_pdu(args...) \
  834. { \
  835. .valid = true, \
  836. - .raw_data = g_memdup(raw_data(args), sizeof(raw_data(args))), \
  837. + .raw_data = g_memdup2(raw_data(args), sizeof(raw_data(args))), \
  838. .raw_size = sizeof(raw_data(args)), \
  839. }
  840. #define raw_pdu_cont(cont, args...) \
  841. { \
  842. .valid = true, \
  843. - .raw_data = g_memdup(raw_data(args), sizeof(raw_data(args))), \
  844. + .raw_data = g_memdup2(raw_data(args), sizeof(raw_data(args))), \
  845. .raw_size = sizeof(raw_data(args)), \
  846. .cont_len = cont, \
  847. }
  848. @@ -66,7 +66,7 @@ struct test_data {
  849. }; \
  850. static struct test_data data; \
  851. data.mtu = _mtu; \
  852. - data.pdu_list = g_memdup(pdus, sizeof(pdus)); \
  853. + data.pdu_list = g_memdup2(pdus, sizeof(pdus)); \
  854. tester_add(name, &data, NULL, test_sdp, NULL); \
  855. } while (0)
  856. @@ -92,7 +92,7 @@ struct test_data_de {
  857. #define define_test_de_attr(name, input, exp) \
  858. do { \
  859. static struct test_data_de data; \
  860. - data.input_data = g_memdup(input, sizeof(input)); \
  861. + data.input_data = g_memdup2(input, sizeof(input)); \
  862. data.input_size = sizeof(input); \
  863. data.expected = exp; \
  864. tester_add("/sdp/DE/ATTR/" name, &data, NULL, \
  865. diff --git a/unit/test-uhid.c b/unit/test-uhid.c
  866. index 001d39a..bfe8369 100644
  867. --- a/unit/test-uhid.c
  868. +++ b/unit/test-uhid.c
  869. @@ -61,7 +61,7 @@ struct context {
  870. }; \
  871. static struct test_data data; \
  872. data.test_name = g_strdup(name); \
  873. - data.pdu_list = g_memdup(pdus, sizeof(pdus)); \
  874. + data.pdu_list = g_memdup2(pdus, sizeof(pdus)); \
  875. tester_add(name, &data, NULL, function, NULL); \
  876. } while (0)
  877. --
  878. 2.31.1