From patchwork Tue Mar 19 15:19:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlad Pruteanu X-Patchwork-Id: 781203 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2071.outbound.protection.outlook.com [40.107.20.71]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 213A4657DE for ; Tue, 19 Mar 2024 15:19:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.71 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710861592; cv=fail; b=PDBSeBCmj1DH75r5ojgKsm3F6QCtMuE4HNe6qw8yaNEbBjIehrPNhOITp7vtW6SbSGcKdGyYddwXgNAzMHEY1DDweklBL78jQbyRcPbm1MiVC1It1iM81nh8xmzAywfoeIo1nEItKxNM/8dBmIOWat0FHJ5th4JSxiTDmVm2ee8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710861592; c=relaxed/simple; bh=FnG+SXqKGNzQSRg3ZXP+76C9VJfgPDH/pdF4mP4vA1w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=SugNsaP41rgnebYMZ08MeqvU1XjSrkvLhFBds1fwsb0P4XmcuKxQNwDpUXVPCejqtIxuxMAHgkd/zsF5rXWfgLyfqqMY5V4qxjYqv3c0tbvN2pd1Drs43kbJYY2O034+DP/S/JP1VQ9fDh3BMFwDRc5SL/pYpsEvusSjidP2rvs= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=MugZN5KT; arc=fail smtp.client-ip=40.107.20.71 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="MugZN5KT" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=keKr4pMjUuXs5tKjKVuZCtpVNb8YSCThfADjDa+fG0jz6glbRt2tcXCERgzpVyIchzEUVR2G0T2Ty+8uTqNN3EC7vTJ4gopyHVLUgYpkpYQhmno0770roToDL5DGZJjmZpBzfgrmbGwie5sbU5pLtse/at285zmCNXW4KDVezGh/pBKnCshPraa4wO9p6GBC09rg8Gj3oma2xMwdAd09H9Mewcefx4RjMT7OkQMcer905eBuPsdcohz5V8ThxWEKl7tZ41uIk4ekXY9ZcCxJJEgKorW76Dcy00zN7hEA0V5dq6zzR6swzWyyKcyRJhYY7yelx3FhekVQzUP59BoWsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=bzTY7k1dtgMKN57pa39PsKIntxdieIfs/JyeolwrPAY=; b=caOWlEopUg2MbVqByd20L7QJIIvx4yknkiam5+j7FEQslA3KAm42c0Pw9A/TrDXkUsRcAibf9DgYfHKQehltoRiyELP7tOuHjGtqfv7VE6Fw6pSFp/RkxbWXwVCTOCP4ajsIzkDGymtyA8XDxxHuNU3eN94aRCD2Kvc4tBG53+JJy3GzMYy/iR5gZ+djJaVnkqG8YKtX7cpefyRNiHwMHueY7MZfMdYNWptBTKaSIEWMik6rsCmRebaknBDRkvmR0DMOYyufyo8nqKguKDKSkvpqj29wqUNGdXCHsqz2fkBm6EgKU6EFTP4NST6ukHGgUkeHECa/pbCH1J/Wg41Ikw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bzTY7k1dtgMKN57pa39PsKIntxdieIfs/JyeolwrPAY=; b=MugZN5KT1vFkoxkotGxDpZUveC0aip6TNSJ1YkrT1n0fg/nmA7yYCjfwbHlccxciF+4O/njBQaV4pzMogrPX+lBHz5NHrO7wkwoXUATCZ8/r39bEvj6eu5xJ27GxLH4m96f4CtVqa78UWROGzEUjrGHfbQuvkQTCJMsOmu5sCwU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB5384.eurprd04.prod.outlook.com (2603:10a6:20b:2b::17) by AS5PR04MB9924.eurprd04.prod.outlook.com (2603:10a6:20b:67e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7386.27; Tue, 19 Mar 2024 15:19:46 +0000 Received: from AM6PR04MB5384.eurprd04.prod.outlook.com ([fe80::58a8:b333:c024:1077]) by AM6PR04MB5384.eurprd04.prod.outlook.com ([fe80::58a8:b333:c024:1077%7]) with mapi id 15.20.7386.025; Tue, 19 Mar 2024 15:19:46 +0000 From: Vlad Pruteanu To: linux-bluetooth@vger.kernel.org Cc: mihai-octavian.urzica@nxp.com, silviu.barbulescu@nxp.com, iulia.tanasescu@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Vlad Pruteanu Subject: [PATCH BlueZ 1/3] shared/util: Add util_iov_append function Date: Tue, 19 Mar 2024 17:19:15 +0200 Message-Id: <20240319151917.834974-2-vlad.pruteanu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240319151917.834974-1-vlad.pruteanu@nxp.com> References: <20240319151917.834974-1-vlad.pruteanu@nxp.com> X-ClientProxiedBy: MI1P293CA0024.ITAP293.PROD.OUTLOOK.COM (2603:10a6:290:3::6) To AM6PR04MB5384.eurprd04.prod.outlook.com (2603:10a6:20b:2b::17) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB5384:EE_|AS5PR04MB9924:EE_ X-MS-Office365-Filtering-Correlation-Id: d6758697-3305-4520-9f82-08dc4828029a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Q3x1CM+DFvcsMclzCF5pcoas8nvnONd4LkNEIzcAADFj9tQ0rtffsdPr34lc4Z4GV38YRNm2VmipB42TjwvYwhS4ggl1AcFLsf9jLwGIw1MOrYklrxOi78s6nvRRHduJqtdXqLyPUBl9DN058ZOfgeS9RJMbjiSCmWOB9KQa9gSYzc88hZTw5wQ84XEKnl/t0yC/naGOf2inV5cH+/ik+IDhA/vAj6d8F1hiOyMIHwwaK6xjLSEzUIWs2VKb1vz2V4+dIrnrhTNcMahVYpzD0otosfzpgTYHAjeQ/ReReN/jehN0vzPjzVl/1DeiKjxBD0CASO6MftdI8gUD+3gEx04vAlkhROqZ5T8pyndhy24FBHdJn7pLMzfPqK+qq4K+mkQ0RmHXG1ISbGIwOj3dUhDN690SDU9kBSIB4vOe0+GbP672Mtg2JCfULs1PT82l5tnnJCi+/AIbxlryZpFFG0Eu+a2MylFFIILIKSOZq2GaSPIY2qMA9DBIHhNVR9xrRSksImKm2Jsf20+GFVuRkijEB0eUgz5pqfZpww70r0ccuohhIsll/hsT14D4wVOz7p7bz6t5NCUvsFucwooyZs0UJ3+qaFFCpPHwGxVnyKcfZYjHgvk8//InnisqgAJUtoCa4L3Nx+ZSU5tmW35wKfey01AdjGkaFLyM8qcl4qgHViIHFlP+0CJVAXaAgoJGmi7WX5IoWbg1diMRWmVSWZ1wsmeqD+p81+OV8I9y4DE= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR04MB5384.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(52116005)(1800799015)(376005)(366007)(38350700005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2bSSmbQKH32/d8vA3TBv7olIkINq6p7zypiLlaLnFJ+szFeYXIHq1/rVWaZDb9WQzeRJdroS+d+LNuBoliPsLdS/NfIYtl8Wo7ofvHgCfI8+vZ59J5r//4m22VlfDroy7Y49A3d2FoEHDO0SWBJyJH1egU8t72T27xmx1nTDr9UOMZ/4t2UtY7ctai6Fh+stoySZgLF+blIXZDmdMcX0Fr69zkA9dbKKfLWg8maoP9V8kU6sKw07yd+26fRM73RneNhhaNog9ATYlSO28vxiXPNdR8sIEShhrFJFplviK6yjiGHMlneKMQKQGL5TKFd86672ZmwPg/Dx40+U8XDyLm3kuTZuFAtngt1XntyRj79lMW+hzzkaAiDkRJ2giHX/W3bnG6Jbkm0DcfPoj3dc+rSmgkg6Sz2y9WHdm+4swjA8M7WsrTmlYbh5BHQX3+PRg4eY1gEGrM8WzH1OKI3Y0yYMM8KcyyDcWUs0ZfnqKF9dWiw8J0yksuC2xe5Pb53S/N8ot0BARYAF9wqO1YwKFpzBmcIlqdXOI5M++WLzRnAv13B/MsS7/XdHpDsKD7iHKZqWkhH0ZZnN8B4KR7nIiU90O+/NKpfAuDMy4pRu+Ks1PmZrnf67m5p8Um5AuKpdcXG4VgdlleE7oyrHdhnGymoLx4hGcoTvXu3Nbt9xrnU6F6A91Mn06S7phM9JF06j82VvjrL8RF2xtAgOC5Bd3RNNxC++Vm3HuvOahE9e1zEXZ4WNIgZLkWJAvuN1V7j1aBERyJypwg0GjRNJGdGRJNFuycFVKJAgX46JH2a18SHWii8HkOr0j+ryb8BYmTO14OItmg4lXGvBudzy4sR5hg6TJKYTqwtW0Hd3vFz70KqLKvo7mq/IRs+yor6MLz6D7zZjGQcfR/HW3YXMP0gf/stCNp0+4g7rDbqzYDZVMdLLRxEkY3bpcmf6ZmUpZ5MIlCK3/4rIelxi+9C2iE0BB9LgunB6/4oS1VfAu8i8J/E8bElvLl/Frtsh49UBeBHVKxI3P4r+uIWD9h88MB+SSQf+KLYsgheUWnAIpwP6Z2XDmcjXqfzWemRd0lS2bS1DJWsppBZo0cgcIFJGK15cByTntQNEkXx3GX80sMfY4r/tyKzs/nXM7+PYa9JW//LEAbdnqtNrSXbBZCc72aX8EL7JvzQM31mFqv8F0DzgecjF4YAAz0pj7t02DFdbzHnpN48uJHbXacaYh82k/gLPeq9NcNW6+IhAd2qJPEIOdtT5EMma+toskuW3cKg9gvUXZhFt/KX7SWZbc4Jzn/oCN4oIUJjUvheCUBMyuI2SRT74aHw4lqBfWQa1UdA0N1DnfKivC+vL2wsPibOS+PFOzFeeuUjyfwDqBs+vjQygrwX8UAPICyFOezjBs1mHuFHKj5qLct1tOFvbOqZ301nWxSn4k8C2GgxGogdOs3F7QRkqb5Ih5tyPTXttjTFiuWZoGyjAgzh1z1V2j3VzS7XB10mG53B18P3EwsarwFCzG1UOdf7FDlGfMuiIlpS833PzHk6Mf7CCU6VJN40/60SbP2JJQkC1+pKwTlT+VxJofovUcfZRhuGugKAXpAv/tQRE X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d6758697-3305-4520-9f82-08dc4828029a X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB5384.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Mar 2024 15:19:46.1076 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: WqwiFyzipNXoKmn5HXOUA1n1pzKjzhoGy5DUDnSff2WMFlugqSz3JjPLkMtan82a2qwjXC991xiJfYUY9dUeCQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS5PR04MB9924 Currently iov_append is defined in 2 places, client/player.c and src/shared/bap.c. The player.c implementation is faulty as it does not allocate additional memory for the data that it appends to the original iovec. This can cause buffer overflows such as the one attached at the end of this message, which was discovered while running an Unicast setup. Therefore, the implementation from src/shared/bap.c was used to create util_iov_append as it allocates new memory appropriately. ==131878==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000059dda at pc 0x7feee2e70ea3 bp 0x7ffd415773f0 sp 0x7ffd41576b98 WRITE of size 6 at 0x602000059dda thread T0 0 0x7feee2e70ea2 in __interceptor_memcpy ../../../../src/libsanitizer /sanitizer_common/sanitizer_common_interceptors.inc:899 1 0x5579661314aa in memcpy /usr/include/x86_64-linux-gnu/bits/ string_fortified.h:29 2 0x5579661314aa in iov_append client/player.c:2120 3 0x557966132169 in endpoint_select_properties_reply client/player.c:2191 4 0x557966132a6f in endpoint_select_properties client/player.c:2268 5 0x55796616e0b4 in process_message gdbus/object.c:246 --- src/shared/util.c | 6 ++++++ src/shared/util.h | 1 + 2 files changed, 7 insertions(+) diff --git a/src/shared/util.c b/src/shared/util.c index 74d43671c..0e71fda02 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -536,6 +536,12 @@ void *util_iov_push_u8(struct iovec *iov, uint8_t val) return p; } +void *util_iov_append(struct iovec *iov, const void *data, size_t len) +{ + iov->iov_base = realloc(iov->iov_base, iov->iov_len + len); + return util_iov_push_mem(iov, len, data); +} + void *util_iov_pull(struct iovec *iov, size_t len) { if (!iov) diff --git a/src/shared/util.h b/src/shared/util.h index accacc79e..a8ba23499 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -175,6 +175,7 @@ void *util_iov_push_be24(struct iovec *iov, uint32_t val); void *util_iov_push_le16(struct iovec *iov, uint16_t val); void *util_iov_push_be16(struct iovec *iov, uint16_t val); void *util_iov_push_u8(struct iovec *iov, uint8_t val); +void *util_iov_append(struct iovec *iov, const void *data, size_t len); void *util_iov_pull(struct iovec *iov, size_t len); void *util_iov_pull_mem(struct iovec *iov, size_t len); void *util_iov_pull_le64(struct iovec *iov, uint64_t *val); From patchwork Tue Mar 19 15:19:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlad Pruteanu X-Patchwork-Id: 781399 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2071.outbound.protection.outlook.com [40.107.20.71]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 93E92651B1 for ; Tue, 19 Mar 2024 15:19:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.71 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710861594; cv=fail; b=IJEgllhu/7u7RBhumT0dmsp8MRYlv2xy2DJrq47A5DNKL4SoJ7w4UCcApKn2vM/piM8rrl/VagQkyZ7XLBvA9Z4F3tpLvXPq2f1a7R1IE1nlUopiYmpbtTvSijMtl+LxEEyStPi3PrOvN+3YD2Cz+sld3dPEGeg573Z0kObLBBI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710861594; c=relaxed/simple; bh=LJrj4Ha1MfBfo8uDdgbOvPcAeZUPoij8uCFBJ97vJPM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=QkcH8a6FOob97MrlAMK21OYer3OGFV5xJHV6FjzVDDd8t+zbeCpijoB7pNwAfzC5IsZ/L8Dw146jIYXUFR7FDthcklk6cWW39OtFAF/tSXPjou2yV6SP7+8RoyV3h2WvFDEwblzedS01B+4u9PLX68LSdSWAore76YbM/zsENto= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=TXTZwc9u; arc=fail smtp.client-ip=40.107.20.71 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="TXTZwc9u" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eUig5iM3TuuTP5BgiM5TIdRtocsYTh4ErLFIHmdDEm0Iw48GfLBeikG1WZOW1ruN+BGRImAwhNtDP1SumCBvvT72qfX5j/pEbzi/jwnElvXjtAernV9KH4xLdfnnmoGpIAGlpAhoOn4/FWd1c2XqIF0L1Nf3s/q3fE0vhPc99grpijhaR4jmIcCsmls1OQnPPMcXRUNDZRRtNqOXydKQ4rgYw3JOqLfhE7Spm3Het7p28/ZYu21gLe/UjYI/NlAnxSdyWdLGsjFpPbUl1a9yQIFusZZ+jFsGAPTXX/PPhYUAytP8D4SMnEFvhEvKOlq7yZ6jKDFpU0vQBtDNoqNOcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=bvmyuEU1CVxjaB7x878S9kEqZmm2GVYKRtrdODxOf8Q=; b=EsMpFNkNN1+7VXxMz7HJ+DK4hg4YzpYBtyIsfadj+a1YcJQVFS15sQ36OYkHgY+PT51sy+ItH23r/YWHtV22vls7O/hLT0lqfH5yRhHcpMXHt6AhVqnDF3Z8gHni9/rhCp+JDb5515xmbqlPwiglwBQHQJLy0GblNWK3a9tDTYgduSRY2o6f3+jUtmAWnYzEf28hlSBRQ9zDMHlPqberuXJXbdAvoMmzwRACkRwhGsEVVKLKGJxliOuJltSNnMJ7g59qb70Xh11BKtR5upafciLIM43D7LsNXLkY5XnSnQMAQiROSGisWmRTN8GiRB5op9UaBVdNgLKLOw7JO/L22g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bvmyuEU1CVxjaB7x878S9kEqZmm2GVYKRtrdODxOf8Q=; b=TXTZwc9u36lFct31pqpMnFf0BDW+Jc6Y/KgFZYLQ2XNhSJ+uYK1qp2sbzKcE69faobeNA7GrVSkrFvRTnfQOrBAfRRRKIfXRTvLi08bIAYnUu8XMUtGLEqTkLPu2KFLrmqPFb25iFe2WREsAfeU7nXkfUWFfljI49lx05U3IsB8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB5384.eurprd04.prod.outlook.com (2603:10a6:20b:2b::17) by AS5PR04MB9924.eurprd04.prod.outlook.com (2603:10a6:20b:67e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7386.27; Tue, 19 Mar 2024 15:19:50 +0000 Received: from AM6PR04MB5384.eurprd04.prod.outlook.com ([fe80::58a8:b333:c024:1077]) by AM6PR04MB5384.eurprd04.prod.outlook.com ([fe80::58a8:b333:c024:1077%7]) with mapi id 15.20.7386.025; Tue, 19 Mar 2024 15:19:50 +0000 From: Vlad Pruteanu To: linux-bluetooth@vger.kernel.org Cc: mihai-octavian.urzica@nxp.com, silviu.barbulescu@nxp.com, iulia.tanasescu@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Vlad Pruteanu Subject: [PATCH BlueZ 2/3] shared/bap: Use util_iov_append instead of iov_append Date: Tue, 19 Mar 2024 17:19:16 +0200 Message-Id: <20240319151917.834974-3-vlad.pruteanu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240319151917.834974-1-vlad.pruteanu@nxp.com> References: <20240319151917.834974-1-vlad.pruteanu@nxp.com> X-ClientProxiedBy: MI1P293CA0024.ITAP293.PROD.OUTLOOK.COM (2603:10a6:290:3::6) To AM6PR04MB5384.eurprd04.prod.outlook.com (2603:10a6:20b:2b::17) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB5384:EE_|AS5PR04MB9924:EE_ X-MS-Office365-Filtering-Correlation-Id: 54cac218-bfcb-4846-cc19-08dc4828050d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9nn8h6NhYCebrJBLfo8+7YW2Hx1beRsd2QDmcbmKOfPQR/8Iz7+sVPDMM4utJmfcyZmpzdq193biLI1f5b4k3bVuSRm3jn6rclxdYTZl6uYgyw4n4pu9dOBFAFYo6CXCafJACJu5VYRSnfdOyllLDYG/uufsheNRcZEZmGxH1G3bSYs+tiowRaS/dVZlwJrScAgR+eIsVbJ2CjwR80mDaOaKO5iyS8hMY7X5yWV5/1K1H0/8z4Pjgll/q3807AWM3jjLdYGK1XkaA8JcLHVjVF+ZP7HvY40bMj2nM6/SVW/XrehdQjfTBzMjRMCff/04CO7OKxo7HZhoHw8RloA/C4eqG2FBhvxBYiCpEss2LOD6XFtqBjBjnlgXto27Asc/1iSfA1RdYZKScmsMX1shMqGVN8S2xUYW6I4Gcf+IiqK/oAU3dpO0AZcMI2tZBSCnIUra9Cgbpr2odRRPJzj85X85hE6qEwTBrfU/xSPMQJ2r/CBvwUKrxdcm3q6IE8NPXxFkeM8m+crKQcaqiJ+SeHJUAG05IdnMqWUsCIvmefyqioAIihVbFTE+p4mJXV4EBrkXKe0Qjh3xjKqvEIJi67Tl8xquTcv6aKkp+yfSfS8IguSbGe7GCa2zs171bJ8mQ9CKgAuWUeT2ER4ZWq/zo8Y0KaF6jvePJLGPLSBYyny/X+4bSPzxJX6ijdQbhDmP3BCaCeF5wjw3bvCu7bwgFUJrJgakfONggsbxnOxedGc= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR04MB5384.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(52116005)(1800799015)(376005)(366007)(38350700005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: W6oI0E9wZ6gLl0x9xFG+gE0OI324QR+JzgSkPg9KOS8mYIdE4bWhhc9VzV/DZtdzZqUk9kfy8uzFNd0gO3hyVhSPqlXG/s7PacJkGD/kehS3+LMQnwcTWUZVLbCy6Os0hrnedxq/XpBwZEVvygtY7xsre6HkZIWKefeqyVx147UcqCCFiYiwlLqLuAlBgYUYZTmZF8G01169gbDX/GG79opeJ7SNk37wDaHfMqfgHeS+1/vsa86wB81QY4eUvdZuIV93SgrlO9Z6LqbhX1vrrKO3qSXfnZqQTHKLp0Z9erpEk+nLDAzIIXl712aUbvhYG6a6usYhaR+SJhQYdPNPuCIuwlr3jrgYoqZBznrk9pNmHzA/bTuCstByVJMRRAbuX3jqCAQrmQugg/JLS9mcg85/ti3PFDl17SK0CInIdMWmkrdxXrORaok37XOrp9jgRcLVK31Ig31JZi6XuXoZoTNFSnJrR1EY20wjTUqGkj0+LOSrVBWpeAlDMbeUWRmvwS69b4q3zF18KR/A90DQJKl88JDkHEQsvGCheNqh7AVXzsVjRpIXQbnO5MzIMUmMf8KXcWDhLWlXIQX64P6maOw2KU3uEx0HXyk5YBgQNjDlhYIm/qVp8RREQvfuChYnnDY0/SFsgVjkI5IvAbJIKBPrC0RIKnMneD+4oWz/QjxtXHkutRHUR6/NBfb6Ap9Xjs+3m1bX964cmDZrgIeOazT9dD1YJoCW0UPfrngdBKiP9TC/x5lY6RaOHx4h547dVJ0g8yToIIzgVKupxuIkUbW4Rt2O5YAxWfizMhUUv2xKIBYPAibVy7M7i/PGkIFQVvW3Zi/gF0VouXvn6xsXjTA6EDQBshdouLaMsNenqYHv86Djz3ZPEXUThvpL6+xXUSBngFsEWnfCo+c3Hlku053w9PUiUYY+NTUlz/tfeLoAHAYVmHGMNC98mbnWQL+PCJMlmHeYSemV8dwP1BK+YneJA99Fj34taHogK2SX+WxkHQ9D3T3xuQFUS5Ezrg8GR+2+D7/wDgGoQMDMEM++QB6hhYRFCcMKMAnM66XGY2mgv2VPesLDusjq45RZaqyHLoqYx6arycPryGywmSFeK6StwN3HXldu7pFoDj7LLBvLcN7DJQQOwpKTXUUolhn1+RfyzzUGDH6Tyt3gYBmgqVQES2rpB+6a2MHy+zWm0GSirvjsHMXLlEodPSvFm7UfpaK0tftekb0KK1OIsD+z2gPhDYklIjD1z3udaJxvyOl4ZAJfWR5g/3zrVMGFKiqZQQC8Q02hsuh+1htjExziXliX3q4OpZq6LDGtQ/U/HuiVWK6ZojWKY6FKROczRlK6SHI9N+F4Ssk7ijVFW3OhtQkq4ak1Za4WBBl52ZTp++YR2W2a3w3X7XpgeQd9ZAOHWzUHkcD7PWSdLoKlVYHWBXCrq7Xi6mqibz/apvPbI5rZlIMJrcJfxO6vWdZGK9/uMNYrV/lMP5dKW8OBvExPDquV8BzSp5GKBGQxGAmqXR0ADT3kXsb93YblFhn4OwD/M+kvVVuIbP6Mdif58pmLFghLAz6RtUvSDguPo1R3FMfJJYoRjLQnqRLDF5jtRHGS X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 54cac218-bfcb-4846-cc19-08dc4828050d X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB5384.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Mar 2024 15:19:50.1980 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: TFuCV34/D1jG6HN3CNkK3jKRruui4GnzTGRcY1LZqJEcjMjti2JpJLOHdKehvFsWqebapMr1z40GZXtRZj6+xg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS5PR04MB9924 Use the newly created util_iov_append function from src/shared/bap.c. --- src/shared/bap.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/shared/bap.c b/src/shared/bap.c index fd99cbbca..a1749153b 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -326,12 +326,6 @@ static bool bap_db_match(const void *data, const void *match_data) return (bdb->db == db); } -static void *iov_append(struct iovec *iov, size_t len, const void *d) -{ - iov->iov_base = realloc(iov->iov_base, iov->iov_len + len); - return util_iov_push_mem(iov, len, d); -} - unsigned int bt_bap_pac_register(struct bt_bap *bap, bt_bap_pac_func_t added, bt_bap_pac_func_t removed, void *user_data, bt_bap_destroy_func_t destroy) @@ -3049,9 +3043,9 @@ static void *ltv_merge(struct iovec *data, struct iovec *cont) if (!cont || !cont->iov_len || !cont->iov_base) return data->iov_base; - iov_append(data, sizeof(delimiter), &delimiter); + util_iov_append(data, &delimiter, sizeof(delimiter)); - return iov_append(data, cont->iov_len, cont->iov_base); + return util_iov_append(data, cont->iov_base, cont->iov_len); } static void bap_pac_foreach_channel(size_t i, uint8_t l, uint8_t t, uint8_t *v, @@ -6081,9 +6075,9 @@ static void extract_ltv(size_t i, uint8_t l, uint8_t t, uint8_t *v, if (!ltv_match.found) { ltv_len = l + 1; - iov_append(ext_data->result, 1, <v_len); - iov_append(ext_data->result, 1, &t); - iov_append(ext_data->result, l, v); + util_iov_append(ext_data->result, <v_len, 1); + util_iov_append(ext_data->result, &t, 1); + util_iov_append(ext_data->result, v, l); } } From patchwork Tue Mar 19 15:19:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlad Pruteanu X-Patchwork-Id: 781202 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2071.outbound.protection.outlook.com [40.107.20.71]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 05DBD651BD for ; Tue, 19 Mar 2024 15:19:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.71 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710861597; cv=fail; b=WFfD4m1Oey4zT+AK0W5y/e/zS4crT+JfE0bnf6mcsiWv8l3INZhiz/HAYh1S3/H3rjQroJD/Y6B/e5gLQeBsbcCxQU+reE379fCB+XBOMiZvMKfiywqjieWoyAQGRGL92XmgMXI8jp9C7PXIPfeZNwiDkrSE7LXqO5R41wE077w= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710861597; c=relaxed/simple; bh=zMuoZE2zqqv9UOgf4XZ8MCJoBxdWNBc4DspwcZO7RZE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=AOCYmA7+/qAfL1JgYiA8mPbih5WT5f68k2RrWJAPXyGZgyu+PGiukDdYyPjXmKN+kVDqtvC7M/1TZgcclhppG/B3op8tjdrUt/Ph4EV7fuS5XIWb+Np8uZMjO+U19yFK3/IWgA10p03xmrMNsvTvL3+JRdtZvDSlwoyHf/5abD0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=VCOoWUq+; arc=fail smtp.client-ip=40.107.20.71 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="VCOoWUq+" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LZeb1y5v45ACaoRTNxBKWs17uenJm6wvW+QrbUxvr7zhg3+G0y3Qx4ld793+7cyHNN0Fmvh2zUEESfo7iYZ57UNO8fwYUiEk9gIWodUksmGZGJ40XzRPdzVCVw2HVv3T35RtVofw0sP0Da+50zxqoX1/SIqjl+2lXsXtt1RavM+a6joY35iZF0qKGUiu3o4lh7F4Vt8HIJ+DLFFbX8aEEx88Ts05E8KMHLFKbFj0oTn6JP4LfgVsCuA5Ctqhs0mmDArFPysWHfsfpXpwBXAxUtspMGqm3wHAjqlvSl+2yFPQBN40S7081uiy/p27Uu2cVQwj0r+O3ozr+rpW/HY1wQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=35Q1liWkj8ChkWrx/0c2AaibPDzXrvRrXQs3Dgaica4=; b=UA4g/lS7nLo+0JXufgpKLQStOxvrta/kVH5e9mlD1RYdi69j1udrB5QZGf2st1RpOlWQ2Nw7TRO1+5O89zoxA2CVkwc3+DuZUyyMMpxXHQnuruSP7plnbMpysfX4ljBqVXD2esu7U9cMtP0D3W3r+TJ0hA8OCBy/83VoGVXuVQVKszzNMPcUF3jsASND+37jP1zbBQLXtAjzAlwYfcRZCe/MJ8Yf/879aNN/WMtUXDbMiVcAFzCfG/kOaEJQnccP38aubIiUHOcOqbM3/+QEhcqXjSIg3OUjSXNpKpfjjG+eSjCKdSeICIZoBpbXADBV29sRxFVIWdwspDzdlScomg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=35Q1liWkj8ChkWrx/0c2AaibPDzXrvRrXQs3Dgaica4=; b=VCOoWUq+cn957K5ofmDmLdvPHht4rLILxsIu3vvpMhs1iEiVuPtS1U+tjxHOJ3MRZfCB+BWKJG6ygLuTPEmvFgDCKaO6WsaLXYLYDCZvUPaWo8kmMokyTCmhYxwRj8kPvgUobfSuINB9UpjynrGmEts6BbuBObAvhAWKHBadipM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB5384.eurprd04.prod.outlook.com (2603:10a6:20b:2b::17) by AS5PR04MB9924.eurprd04.prod.outlook.com (2603:10a6:20b:67e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7386.27; Tue, 19 Mar 2024 15:19:54 +0000 Received: from AM6PR04MB5384.eurprd04.prod.outlook.com ([fe80::58a8:b333:c024:1077]) by AM6PR04MB5384.eurprd04.prod.outlook.com ([fe80::58a8:b333:c024:1077%7]) with mapi id 15.20.7386.025; Tue, 19 Mar 2024 15:19:53 +0000 From: Vlad Pruteanu To: linux-bluetooth@vger.kernel.org Cc: mihai-octavian.urzica@nxp.com, silviu.barbulescu@nxp.com, iulia.tanasescu@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Vlad Pruteanu Subject: [PATCH BlueZ 3/3] client/player: Use util_iov_append instead of iov_append Date: Tue, 19 Mar 2024 17:19:17 +0200 Message-Id: <20240319151917.834974-4-vlad.pruteanu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240319151917.834974-1-vlad.pruteanu@nxp.com> References: <20240319151917.834974-1-vlad.pruteanu@nxp.com> X-ClientProxiedBy: MI1P293CA0024.ITAP293.PROD.OUTLOOK.COM (2603:10a6:290:3::6) To AM6PR04MB5384.eurprd04.prod.outlook.com (2603:10a6:20b:2b::17) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB5384:EE_|AS5PR04MB9924:EE_ X-MS-Office365-Filtering-Correlation-Id: 6916d720-479a-4875-b93d-08dc48280728 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZJcSUpqsemK0Dg+BxgdH4mj1+zOn8bOARqv/anCzM3RuS7vMPCAInpW1i5Hy34Fmr86bRSF+gODzFPYYku3uNo/TUWxXK+81m9DEaim6612P2TZ7shmAlBwhOcM+GBnMnxBaBDcJhjXQK+gqkri+Gr62uvVHI+/DPrrhCjKy2I0YMdw9gvOxf65yvKhFQ0mmnlU3MKQ311bZErwn/iZvYk/4N37ZTjqTfXLCHMF41dOmNPh9ZdLk4L9qkmtgY0y9I0mrPG6rCcR1AzkUeZKH1M93x1gNz9YJu3+VfcqzkfJYosbwG90Ba7VDiKhwhEwKAj5zFSTrCMleiNSyivt0wRr5VvFy0QNAG7/yTI2JE/8HvOkMeb9ADueswzno6h8wGFSUOtHXbn+HUa/7rTmfpmjrltFGvAqgYGSweJ/yGDl+H+b8xEEEoeyonIzLMVupFFSpHauu6TGRVANGXs7dkmfbAgpngpCHlIiWXUZPmg+V2Ui3KuTXk0+SZdhttzvRWUemP8cIWRicFvjV3leIxt4v/HxQbaXwdr1FfsNueVIAMY/Nli9yvUOge7s3bu57APZR/mJdQkgG/lRhL+RDki5qt+ES7h3J3F43qFSGYCorv02/h0KyKrYjl9Cl3/1osomgv2WiN+ErhwwWEeatASwrh0GOKvCrRLOLs/gA6zL30byx9RJQ7b3O76sJc32uYlngQSCi+Ew5Kf9z2r35kl9A9QJuHbTaCCYPaq+CJX4= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR04MB5384.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(52116005)(1800799015)(376005)(366007)(38350700005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: yTd3zuyReIOxxJWOxlNJrniKRMqIQiv7elVV4G9sDSih5fWU2H4r8Y3e90Yox9UdmncwddxgxzuAvDp1oT6cOmyv9asmCGGadc+oP9yTW2i5F7y3RZI236WMzjjOAs3BiHmfdc1acF/UMdp5CgzFuNXQYfjrvOYrFhaXz+/goBHV2u/0sf8LsMws+MUjFkSVTGucWEwugyhiHVsvQA1aUiD8reVjgvWlO2tuip3uLpUWZhi3C5b8CfOuXN/zBEURr88katXu00LYrdwJuVaKd/E4L3ZRi2Z22kRl2GdSBMS7szH7PcyvwqTNM0GxJbNM65VOWOID49rKYk2C3GHN/3BgGXgLUzD81879gHlRjzL2r7u90zkZ+2HA4sZWvICvZnsqNEt8VVzhe3vg8+6ku/usrHYrWH4XcK8DbvofEUk1kXroHAkNxU+o8Y0mU2KzBIXLMabkTf9EX/vOJMRpZWMUU68FoLSpd7ZdWeEDQiKJ6Xwi9jWQDJzGSKmFkptbiotWJiS+GF0ifLBcVEVaPvXQPR6rM8zl0V4zShP3A2zkk0dJ6E4qYE5aLcInc1vyMRBSiIhM6cCg25SHlQQrns/FLWmFCi9h/R/6VaI2xgofCUdTdJAwsffFHJj/mzlltboBZMiADqEo+MPRPrrlw1teHihGUscJXFy6kZry4i+KbCW9qADo6xpvLaOEDuaHEx+RhL817So0cgESxgjQK6tGtabtlRsc8cZfP8NXRHLPD65ufn+QpgdDqRC36f6ngu4lTFt/mefogRzlbmh89v9/6MvBkAVSp2Cg8LRDo73kphMh5EKteH7T8cbqcfyKirv5zcXhkM79aeIudctmhHMG/76EM2tl3m5sYAhO4Q4Q3p1CGlXQJU4J2XQhujw8LWeYYhRBABInhkow+2At9avgZMt3IAgMqzcm8L6OTLYSLeT9/6Gskz0q5+U43mQQEVEAVEADnQIbaEm9z2bSdJJgY9kz0QG01rcy5TRaC5TvXizGhFbUhna7IybeCs7xzLzTxm377JhYpZvSc1FLlbj8z961QruFsbzGc8xcZqXfzS2bi7WEUHMqjlXLzFvpjIGesMxbEliq39kxMDcjMUswgb+V87GWhidEbRdpX0H8lqAlYKwYytE2kubwHLYsp4Y0ztwC2NGWOu2sDdD1aHNbScexcWloTtx2ogBr3Zi8onn5iMPHFhkPYT11I8OlDWXa9LWM0jt9MxkeKkWViiDLmHvrv+LJCet3a1ir/yxzpLT09kLyGBVb0LbBK2P4rPyth3X6ZUX6sqQov6++S3kvWwj+eQiGtzSI5uFyfyeu+KD7KwNvtqSyV3Igt7Wxc3xPydetasFUfiBNbSxdrt5xGFhc1F6VkvUtrhTETgzx08Z6kWKlqqaZMPJbxkSiW3mTDbEtZ1WxezJh1zP9HpFP+yXLF6+Bu8GOARHHX4n5x7Gwo9FYiuFW28BWI1oNwf+jdPKYeKVSbGMS15UbBGDXy6tWvvSTZOTG274DAMoXF94aHzsQ9b/j0iebYRBgSZXOpSyEtdQxh0zh2kJJhZb4DF8jD/N6DD1HoccCIcDjnCtsz5qq03RcwuwSYSU5 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6916d720-479a-4875-b93d-08dc48280728 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB5384.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Mar 2024 15:19:53.8836 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 842uRRZnit5eMCk76az4kQos5S5RKEGIpRZLw5tsECIfzCgPWVFT40OrVb8o53Yl69C0f9Ehx8AfN8eM1XweCQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS5PR04MB9924 util_iov_append has been recently created. This implementation allocates new memory for the appended data, while the old version of iov_append from client/player.c did not. This could lead to crashes in some scenarios, such as Unicast. --- client/player.c | 35 ++++++++++------------------------- 1 file changed, 10 insertions(+), 25 deletions(-) diff --git a/client/player.c b/client/player.c index 8081ddc13..ab33bfc46 100644 --- a/client/player.c +++ b/client/player.c @@ -1951,23 +1951,6 @@ static void append_properties(DBusMessageIter *iter, dbus_message_iter_close_container(iter, &dict); } -static struct iovec *iov_append(struct iovec **iov, const void *data, - size_t len) -{ - if (!*iov) - *iov = new0(struct iovec, 1); - - if (!((*iov)->iov_base)) - (*iov)->iov_base = new0(uint8_t, UINT8_MAX); - - if (data && len) { - memcpy((*iov)->iov_base + (*iov)->iov_len, data, len); - (*iov)->iov_len += len; - } - - return *iov; -} - static int parse_chan_alloc(DBusMessageIter *iter, uint32_t *location, uint8_t *channels) { @@ -2033,7 +2016,8 @@ static DBusMessage *endpoint_select_properties_reply(struct endpoint *ep, location >> 8, location >> 16, location >> 24 }; - iov_append(&cfg->caps, &chan_alloc_ltv, sizeof(chan_alloc_ltv)); + util_iov_append(cfg->caps, &chan_alloc_ltv, + sizeof(chan_alloc_ltv)); } /* Copy metadata */ @@ -3540,7 +3524,7 @@ static void endpoint_config(const char *input, void *user_data) data = str2bytearray((char *) input, &len); - iov_append(&cfg->caps, data, len); + util_iov_append(cfg->caps, data, len); free(data); endpoint_set_config(cfg); @@ -3662,7 +3646,7 @@ static void config_endpoint_iso_group(const char *input, void *user_data) static void endpoint_set_config_bcast(struct endpoint_config *cfg) { cfg->ep->bcode = g_new0(struct iovec, 1); - iov_append(&cfg->ep->bcode, bcast_code, + util_iov_append(cfg->ep->bcode, bcast_code, sizeof(bcast_code)); if ((strcmp(cfg->ep->uuid, BAA_SERVICE_UUID) == 0)) { @@ -3707,8 +3691,9 @@ static void cmd_config_endpoint(int argc, char *argv[]) goto fail; } + cfg->caps = g_new0(struct iovec, 1); /* Copy capabilities */ - iov_append(&cfg->caps, preset->data.iov_base, + util_iov_append(cfg->caps, preset->data.iov_base, preset->data.iov_len); /* Set QoS parameters */ @@ -3937,7 +3922,7 @@ static void custom_length(const char *input, void *user_data) ltv[2] = len; ltv[3] = len >> 8; - iov_append(&iov, ltv, sizeof(ltv)); + util_iov_append(iov, ltv, sizeof(ltv)); bt_shell_prompt_input("QoS", "Enter Target Latency " "(Low, Balance, High):", @@ -3963,7 +3948,7 @@ static void custom_location(const char *input, void *user_data) location = cpu_to_le32(location); memcpy(<v[2], &location, sizeof(location)); - iov_append(&iov, ltv, sizeof(ltv)); + util_iov_append(iov, ltv, sizeof(ltv)); } bt_shell_prompt_input("Codec", "Enter frame length:", @@ -4006,7 +3991,7 @@ static void custom_duration(const char *input, void *user_data) return bt_shell_noninteractive_quit(EXIT_FAILURE); } - iov_append(&iov, ltv, sizeof(ltv)); + util_iov_append(iov, ltv, sizeof(ltv)); bt_shell_prompt_input("Codec", "Enter channel allocation:", custom_location, user_data); @@ -4074,7 +4059,7 @@ static void custom_frequency(const char *input, void *user_data) free(iov->iov_base); iov->iov_base = NULL; iov->iov_len = 0; - iov_append(&iov, ltv, sizeof(ltv)); + util_iov_append(iov, ltv, sizeof(ltv)); bt_shell_prompt_input("Codec", "Enter frame duration (ms):", custom_duration, user_data);