2023-05-05 20:33:30

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: [PATCH BlueZ 2/2] monitor: Fix misaligment errors

From: Luiz Augusto von Dentz <[email protected]>

This fixes the following errors:

monitor/packet.c:11968:27: runtime error: member access within
misaligned address 0x565448026d55 for type
'const struct monitor_l2cap_hdr', which requires 2 byte alignment
monitor/packet.c:11968:4: runtime error: member access within
misaligned address 0x565448026d55 for type
'const struct monitor_l2cap_hdr', which requires 2 byte alignment
---
monitor/packet.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/monitor/packet.c b/monitor/packet.c
index 645e3f97ef40..94561b65ea75 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -11945,7 +11945,7 @@ void packet_system_note(struct timeval *tv, struct ucred *cred,
struct monitor_l2cap_hdr {
uint16_t cid;
uint16_t psm;
-};
+} __attribute__((packed));

static void packet_decode(struct timeval *tv, struct ucred *cred, char dir,
uint16_t index, const char *color,
@@ -11964,7 +11964,8 @@ static void packet_decode(struct timeval *tv, struct ucred *cred, char dir,
NULL);

/* Discard last byte since it just a filler */
- l2cap_frame(index, dir == '>', 0, hdr->cid, hdr->psm,
+ l2cap_frame(index, dir == '>', 0,
+ le16_to_cpu(hdr->cid), le16_to_cpu(hdr->psm),
data + sizeof(*hdr), size - (sizeof(*hdr) + 1));
}

--
2.40.0