IsoTpMessage: check CAN frame length (#1312)

* add some more sanity checks for _isotp_rx_next

* another PR

* revert
This commit is contained in:
Shane Smiskol 2023-03-30 22:14:35 -07:00 committed by GitHub
parent 12b9b65985
commit 9349337ebb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -457,6 +457,9 @@ class IsoTpMessage():
print(f"ISO-TP: RESPONSE - {hex(self._can_client.rx_addr)} 0x{bytes.hex(self.rx_dat)}")
def _isotp_rx_next(self, rx_data: bytes) -> None:
# ISO 15765-2 specifies an eight byte CAN frame for ISO-TP communication
assert len(rx_data) == 8, f"isotp - rx: invalid CAN frame length: {len(rx_data)}"
# single rx_frame
if rx_data[0] >> 4 == 0x0:
self.rx_len = rx_data[0] & 0xFF