shared/gatt: Use util_iov helpers for PDU handling
Status from this message: This series was applied to bluetooth/bluez.git (master)
Get series with b4
b4 am [email protected]Versions newest first
Patches in v1 Applied
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH BlueZ v1 00/10] shared/gatt: Use util_iov helpers for PDU handling
From: Luiz Augusto von Dentz <[email protected]>
This converts src/shared/{att,gatt-server,gatt-client,gatt-helpers} to build and parse PDUs with the util_iov_pull_* and util_iov_push_* helpers rather than pointer arithmetic on the PDU, so that the bounds check is part of the access.
The conversion is meant to be behavior preserving, the existing unit/test-gatt tests pass unchanged. It is followed by tests for malformed PDUs, which the original code already rejected, so these are regression coverage for the converted paths, and by fixes for bugs found while reading the code:
- the authorize callback was called with handle 0 for writes (reproduced by a new test)
- a failure to store prepared write data sent two responses
- the Execute Write registration failure returned NULL for a bool
- handle_notify leaked a bt_att reference when the signature of a Signed Write Command could not be verified
- handle_notify subtracted the signature length once per handler
The last four have no unit test: the prepare write failure is only reachable by an allocation failure, and the signature paths need a signing key and crypto setup that unit/test-gatt does not have.
Note that "make check" runs the tests under valgrind, which reports uninitialised bytes in bt_log_open() for unit/test-gatt both before and after this series in the environment used.
Luiz Augusto von Dentz (10):
shared/att: Use util_iov helpers to build and parse PDUs shared/gatt-server: Use util_iov helpers to build and parse PDUs shared/gatt-helpers: Use util_iov helpers to build and parse PDUs shared/gatt-client: Use util_iov helpers to build and parse PDUs unit/test-gatt: Add malformed PDU tests shared/gatt-server: Fix authorize callback getting handle 0 on write shared/gatt-server: Fix double response on prepare write failure shared/gatt-server: Fix return value of handler registration shared/att: Fix reference leak on signature verification failure shared/att: Fix signature length subtracted once per handler
src/shared/att.c | 38 +++- src/shared/gatt-client.c | 203 ++++++++--------- src/shared/gatt-helpers.c | 452 +++++++++++++++++++++++++------------- src/shared/gatt-server.c | 380 ++++++++++++++++---------------- unit/test-gatt.c | 214 +++++++++++++++++- 5 files changed, 821 insertions(+), 466 deletions(-)
Signature · 1 line
2.56.0