[PATCH v1] monitor: Fix decoding Read Local Supported Codec Capabilities

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Codec capabilities wern't properly decoded due to wrong offset

< HCI Command: Read Local Supported Codec Capabilities (0x04|0x000e) plen 7
        Codec: A-law log (0x01)
        Logical Transport Type: 0x01
          Codec supported over BR/EDR ACL
        Direction: Input (Host to Controller) (0x00)
> HCI Event: Command Complete (0x0e) plen 18
      Read Local Supported Codec Capabilities (0x04|0x000e) ncmd 1
        Status: Success (0x00)
        Number of codec capabilities: 3
         Capabilities #0:
        aa bb cc dd                                      ....
         Capabilities #1:
        11 22 33 44 55                                   ."3DU
         Capabilities #2:
        ff                                               .
---
 monitor/packet.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/monitor/packet.c b/monitor/packet.c
index fb265028c213..75b61d57aa7c 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -6032,23 +6032,23 @@ static void read_local_codec_caps_rsp(const void *data, uint8_t size)
 	print_status(rsp->status);
 	print_field("Number of codec capabilities: %d", rsp->num);
 
-	data += sizeof(rsp);
-	size -= sizeof(rsp);
+	data += sizeof(*rsp);
+	size -= sizeof(*rsp);
 
 	for (i = 0; i < rsp->num; i++) {
 		const struct bt_hci_codec_caps *caps = data;
 
-		if (size < sizeof(caps)) {
+		if (size < sizeof(*caps)) {
 			print_field("Invalid capabilities: %u < %zu",
-						size, sizeof(caps));
+						size, sizeof(*caps));
 			return;
 		}
 
 		print_field(" Capabilities #%u:", i);
 		packet_hexdump(caps->data, caps->len);
 
-		data += caps->len;
-		size -= caps->len;
+		data += 1 + caps->len;
+		size -= 1 + caps->len;
 	}
 }
 
-- 
2.17.1




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux