diff options
author | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2022-05-24 17:51:44 -0700 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2022-05-25 12:52:19 -0700 |
commit | 1ffd74a6d4212a165763dc53e58a1b49b6fc5a98 (patch) | |
tree | 5b33cc141f50da603d70d8680e90b39a8fbaaecc /monitor/l2cap.h | |
parent | 2894f1392fbe5e570039e9a753c7065cb8fcbf01 (diff) | |
download | bluez-1ffd74a6d4212a165763dc53e58a1b49b6fc5a98.tar.gz |
monitor/att: Fix parsing of notifications
If there are multiple notifications in the same frame the callback may
alter it when using l2cap_frame_pull helpers, so instead this passes a
cloned frame with just the expected length so callbacks cannot alter
original frame.
Diffstat (limited to 'monitor/l2cap.h')
-rw-r--r-- | monitor/l2cap.h | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/monitor/l2cap.h b/monitor/l2cap.h index 951b411e0..1daeb69be 100644 --- a/monitor/l2cap.h +++ b/monitor/l2cap.h @@ -31,8 +31,8 @@ void l2cap_frame_init(struct l2cap_frame *frame, uint16_t index, bool in, uint16_t cid, uint16_t psm, const void *data, uint16_t size); -static inline void l2cap_frame_pull(struct l2cap_frame *frame, - const struct l2cap_frame *source, uint16_t len) +static inline void l2cap_frame_clone(struct l2cap_frame *frame, + const struct l2cap_frame *source) { if (frame != source) { frame->index = source->index; @@ -43,7 +43,15 @@ static inline void l2cap_frame_pull(struct l2cap_frame *frame, frame->psm = source->psm; frame->chan = source->chan; frame->mode = source->mode; + frame->data = source->data; + frame->size = source->size; } +} + +static inline void l2cap_frame_pull(struct l2cap_frame *frame, + const struct l2cap_frame *source, uint16_t len) +{ + l2cap_frame_clone(frame, source); frame->data = source->data + len; frame->size = source->size - len; |