Skip to content

Raise InvalidPacketError on a truncated ISO data packet#958

Open
devitwise wants to merge 1 commit into
google:mainfrom
devitwise:fix/iso-short-packet-955
Open

Raise InvalidPacketError on a truncated ISO data packet#958
devitwise wants to merge 1 commit into
google:mainfrom
devitwise:fix/iso-short-packet-955

Conversation

@devitwise

Copy link
Copy Markdown

Fixes #955.

HCI_IsoDataPacket.from_bytes() called struct.unpack_from() without first checking the buffer length, so a short packet surfaced the low-level struct.error instead of the InvalidPacketError the sibling from_bytes() parsers raise. A 5-byte ISO packet (data_total_length=0, pb_flag=0b00) reproduces it: the SDU-info read at offset 5 needs 4 bytes that are not present.

This guards each unpack_from with a length check and raises InvalidPacketError, matching HCI_AclDataPacket.from_bytes().

Test: tests/hci_test.py::test_iso_data_packet_too_short (fails with struct.error before the change, passes after). Full hci_test.py suite green.

HCI_IsoDataPacket.from_bytes() called struct.unpack_from() without checking
the buffer length first, so a short packet raised the low-level struct.error
instead of the InvalidPacketError the other from_bytes() parsers raise. A
5-byte ISO packet (data_total_length=0, pb_flag=0b00) reproduces it: the SDU
info read at offset 5 needs 4 bytes that are not there.

Guard each unpack_from with a length check and raise InvalidPacketError,
matching HCI_AclDataPacket.from_bytes().

Fixes google#955.
@google-cla

google-cla Bot commented Jul 10, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@devitwise

Copy link
Copy Markdown
Author

@googlebot I signed it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HCI_IsoDataPacket.from_bytes(): struct.error on a short ISO packet instead of InvalidPacketError

1 participant