Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1714585rwd; Thu, 18 May 2023 16:34:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7QKW1282RA/lWR0L6pEBba/vjha/9QnA4ZyXjMzoFl7uZCTlVPCeH0muw1JuXTAR/WHYFz X-Received: by 2002:a05:6a20:7491:b0:100:6a95:c288 with SMTP id p17-20020a056a20749100b001006a95c288mr854544pzd.7.1684452867037; Thu, 18 May 2023 16:34:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684452867; cv=none; d=google.com; s=arc-20160816; b=NXjwg6QTOLOg4rYIdK3kG7qIvShtoKEtBtnR3YZi6c1nbXTgsrTbS1oYlTfU3WiT/r nQzB4C2EjQ6QtNIabfUJxnHMxQTpexDJJIAZM+XY4iZd5cG1IrWpcsto9+kzSpmZl09C N+U8M4i9QkMMSsTvGzlry0P4e6cfCbyCWLLpUTI1TXQIxu9rFVXEdEXVVDg1AnhUSgNA SAfXM09iNQlBM2+GR17kQTfRsMjDnKyfJQkUVbUrUg3KETWVnjwylKmQRUb8bSW5VwQh BZCUG9Ac3TSE29skp3rrVECQmO5LcNt7F0XeQXikXxiozcMZft4+/JXyTeGvIstFRDtY 8Xjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:to:from:dkim-signature; bh=HmisroU8fdM2kRonVoSx6KAHWRO5YgGqd9NTVomyq8c=; b=dW1RqvwMgwVB3Nh0ZhQLle328DRdVEaXQHGV2dnOjEue3l5ZdQdER5Pe/RAK34WqEZ GL/KzouWVWOOCgtBkvv0nqDKs4XdP7NJKpDXwOS8RTSQtHywkdVgEei2jiQGCvmkW2xL MQ9/M2d2F/JhN0t2GDMwVARNqT3Z87pROdpXN1/gUbQFQ9Nh1WmaaeUGjA9SeKLpE3vK 3rR9rGABpv9nos8CrQglQKPxldtvxZQxWoiy0dnqS9NUdGyxwn/GfOxFeEbO1JbBg6mx ifcqD2U5wBT8T4CFsdIs2MalY2KWBs1DsOFfOZAmvkKd+TBtiSgXPuGUWJ/nnj8wzwWd rWKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=JyDE3UzY; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z1-20020a63c041000000b00534839d1219si1156677pgi.138.2023.05.18.16.34.03; Thu, 18 May 2023 16:34:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=JyDE3UzY; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230012AbjERXUz (ORCPT + 99 others); Thu, 18 May 2023 19:20:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229555AbjERXUy (ORCPT ); Thu, 18 May 2023 19:20:54 -0400 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 692AAE49 for ; Thu, 18 May 2023 16:20:53 -0700 (PDT) Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-64a9335a8e7so177883b3a.0 for ; Thu, 18 May 2023 16:20:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684452052; x=1687044052; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=HmisroU8fdM2kRonVoSx6KAHWRO5YgGqd9NTVomyq8c=; b=JyDE3UzY/UQv+LpsE2l23f1Q4j4IehUJSaBv0vTieBSb+fGAjYvi/z2Ce6BS8zpeM/ nUVI0toBjy98J+vu24mMPyBuuhw69mTfPjFLksBbMaghpQpVw5uhfQO7aWlCJdq4qbZc iCctgFNKIUVptUzHOzOrtGD8jo3O4FVg92EhLje7UqsTkBGs8k7dmdOYjwKRav7ChhOr 7vvm0HXkH38pLd628t+XaOE7rXcgwxXMrITB0pGl/BK4UIUFJticvM/jb/dDC41bY5vR 6G1sbbeSmmqBOaY2lOmdiUCh17lBi43b2ltaznJKgqA1gsW8CuLKpAQmERZNd8DsI3F8 1S7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684452052; x=1687044052; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=HmisroU8fdM2kRonVoSx6KAHWRO5YgGqd9NTVomyq8c=; b=REyGfs5BiHzJAI1YOxGZD9pGx+Tt0e9J6GrW/05Czi180rqxt+CMVhhRXkk4ZGWJ2F 0sEzK6iQ4nEhd57KBpL5IOC+C8bY/w3kiEupWksghozTRQMWI4gIXRghbYQKA5kY2zK0 G8ol0Hip03pHzA3sgQE4p7IN/fmGJzwh+q/gzNjdwrNc4C4Dwgr1yJ39VDFbPfgIVwiI nolskj7K012vtoPahH70Agr12tczPVm3BhfBIGY5a3WjJX7Bf9Dv7Yteo+S3bq2VR3yD xqsBG8fjumqJTQoLu/RaociRBZdT8AKLKtOb7Mb4f3gC15/2DhiacUStM2vwb395SbYK oGKg== X-Gm-Message-State: AC+VfDwA29/7ZCgaM1fe/HXVG8Nj743XNts0yCIfXBDlrpBXOKYhkR7l tm6GzLDmME4Bn1yLlM+hlZ3P79MJFm0= X-Received: by 2002:a05:6a21:6d98:b0:102:c96b:f147 with SMTP id wl24-20020a056a216d9800b00102c96bf147mr819657pzb.17.1684452051946; Thu, 18 May 2023 16:20:51 -0700 (PDT) Received: from lvondent-mobl4.. (c-71-59-129-171.hsd1.or.comcast.net. [71.59.129.171]) by smtp.gmail.com with ESMTPSA id q23-20020a62ae17000000b0062dbafced27sm62129pff.27.2023.05.18.16.20.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 16:20:50 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 1/2] monitor: Fix not parsing BT_HCI_EVT_NUM_COMPLETED_PACKETS properly Date: Thu, 18 May 2023 16:20:48 -0700 Message-Id: <20230518232049.1656554-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz BT_HCI_EVT_NUM_COMPLETED_PACKETS may contain multiple handles but the code was just parsing the very first one. --- monitor/packet.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/monitor/packet.c b/monitor/packet.c index aafb81eefb13..39d1f70310e4 100644 --- a/monitor/packet.c +++ b/monitor/packet.c @@ -10293,14 +10293,31 @@ static void role_change_evt(uint16_t index, const void *data, uint8_t size) static void num_completed_packets_evt(uint16_t index, const void *data, uint8_t size) { + struct iovec iov = { (void *)data, size}; const struct bt_hci_evt_num_completed_packets *evt = data; + int i; + + iov_pull(&iov, 1); print_field("Num handles: %d", evt->num_handles); - print_handle(evt->handle); - print_field("Count: %d", le16_to_cpu(evt->count)); - if (size > sizeof(*evt)) - packet_hexdump(data + sizeof(*evt), size - sizeof(*evt)); + for (i = 0; i < evt->num_handles; i++) { + uint16_t handle; + uint16_t count; + + if (!util_iov_pull_le16(&iov, &handle)) + break; + + print_handle_native(handle); + + if (!util_iov_pull_le16(&iov, &count)) + break; + + print_field("Count: %d", le16_to_cpu(evt->count)); + } + + if (iov.iov_len) + packet_hexdump(iov.iov_base, iov.iov_len); } static void mode_change_evt(uint16_t index, const void *data, uint8_t size) -- 2.40.1