Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 084589ff authored by Henri Chataing's avatar Henri Chataing
Browse files

RootCanal: Improve handling of packet parsing errors

Previously simply crashed with ASSERT when an invalid packet
was received. This was problematic for a couple reasons:
 - ASSERT is not always enabled, i.e. some code could be
   executed with invalid packets as input
 - in the android emulator context it is not desirable to
   crash the emulator when receiving an invalid packet

Instead, this patch uses the following handling code when
a parsing error is found
 - report the packet through the invalid packet handler
  (same as generating a bug report with a triggered ASSERT)
 - send a Hardware Error event to the Host to signal invalid
   behavior
 - if in debug mode trigger ASSERT, else ignore the packet

Bug: 323226412
Test: m root-canal
Flag: EXEMPT, tool change
Change-Id: Ibcb89b0fc7f405e3646cfd249a3fad88a668302b
parent e5d2e677
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -345,6 +345,7 @@ cc_test_host {
    srcs: [
        "test/async_manager_unittest.cc",
        "test/h4_parser_unittest.cc",
        "test/invalid_packet_handler_unittest.cc",
        "test/pcap_filter_unittest.cc",
        "test/posix_socket_unittest.cc",
    ],
@@ -356,6 +357,8 @@ cc_test_host {
    ],
    shared_libs: [
        "libbase",
        "libcrypto",
        "libprotobuf-cpp-full",
    ],
    static_libs: [
        "libbt-rootcanal",